run scala with java use spring mvc(java项目加入 scala)
2016-04-15 10:15
477 查看
pomxml 增加scala lib 和编译配置
增加 controller 测试类
有任何问题欢迎一起交流 370798490@qq.com
公司博文: http://it.nfsq.com.cn/index.php/2016/04/15/run-scala-with-java-use-spring-mvc/
增加 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.Controller import org.springframework.web.bind.annotation.{ResponseBody, RequestMethod, RequestMapping} import javax.servlet.http.{HttpServletRequest, HttpServletResponse} import com.nfsq.customer.sync.task.CustomerIncrementSyncTask import org.springframework.beans.factory.annotation.Autowired import 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/
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树