run scala with java use spring mvc(java项目加入 scala)
来源:互联网 发布:数据交换平台子系统 编辑:程序博客网 时间:2024/06/09 20:34
- pomxml 增加scala lib 和编译配置
- 增加 controller 测试类
1. pom.xml 增加scala lib 和编译配置
<!--jdk1.8版本加入或者更高版本的 scala--> <properties> <scala-version>2.10.4</scala-version> </properties> <!-- jdk1.7加入 --> <properties> <scala-version>2.9.3-RC2</scala-version> </properties>
<dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala-version}</version></dependency><plugins> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>compile-scala</id> <phase>compile</phase> <goals> <goal>add-source</goal> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile-scala</id> <phase>test-compile</phase> <goals> <goal>add-source</goal> <goal>testCompile</goal> </goals> </execution> </executions> <configuration> <scalaVersion>${scala-version}</scalaVersion> </configuration> </plugin></plugins>
2. 增加 controller 测试类
import org.springframework.stereotype.Controllerimport org.springframework.web.bind.annotation.{ResponseBody, RequestMethod, RequestMapping}import javax.servlet.http.{HttpServletRequest, HttpServletResponse}import com.nfsq.customer.sync.task.CustomerIncrementSyncTaskimport org.springframework.beans.factory.annotation.Autowiredimport scala.collection.JavaConverters._/** * curl http://127.0.0.1:8080/nfsq_customer_sync/scala/sayHello.json */@Controller@RequestMapping(value = Array("/scala"))class ScalaJobController { /** * sacla say hello demo * @return hello, scala */ @RequestMapping(value = Array("/sayHello.json"), method = Array(RequestMethod.GET)) @ResponseBody def sayHello(): String = { println("hello scala") "hello, scala" } }
有任何问题欢迎一起交流 370798490@qq.com
公司博文: http://it.nfsq.com.cn/index.php/2016/04/15/run-scala-with-java-use-spring-mvc/
0 0
- run scala with java use spring mvc(java项目加入 scala)
- Scala Akka akka-java-spring
- scala-java
- 在Java项目中整合Scala
- IDEA Java/Scala混合项目maven打包
- Maven构建java和scala混编项目
- IDEA Java/Scala混合项目maven打包
- IDEA Java/Scala混合项目maven打包
- 在Java项目中整合Scala
- idea用maven构建java+scala项目
- Maven项目 混合编译Java和Scala
- Scala起步--从Java到Scala
- Scala读书笔记一:从Java到Scala
- scala: Java Iterator 转 Scala Iterator
- java/scala远程调试
- JAVA调用Scala编程
- Java而言,Scala的
- Scala与JAVA交互
- $apply vs $timeout vs $digest vs $evalAsync
- 2015华为提前批招聘经历
- 线性回归原理篇
- 初学-关于屏幕适配记录
- SGU 123 The sum(水~)
- run scala with java use spring mvc(java项目加入 scala)
- Ubuntu14.04 无密码ssh localhost
- Selenium自动化之截图保存现场
- 基于docker ceph环境快速搭建体验
- 数据库设计Step by Step (11)——通用设计模式(系列完结篇)
- 如何优化你的布局层级结构之RelativeLayout和LinearLayout及FrameLayout性能分析
- log4j文件配置在控制台打印sql语句
- 苹果应用商店审核指南中文翻译
- 读书笔记 疯狂Android讲义 第八章数据存储与IO之SharedPrefrences