1.需要添加scala 相关maven配置:

<properties>
<scala.version>2.10.1</scala.version>
<slf4j.version>1.7.7</slf4j.version>
<scala.maven.version>2.10.1</scala.maven.version>
</properties> <repositories>
<repository>
<id>scalaz</id>
<name>scalaz</name>
<url>http://dl.bintray.com/scalaz/releases</url>
</repository>
<repository>
<id>mvnrepository</id>
<name>Derbysoft Release Repository</name>
<url>http://search.maven.org/remotecontent?filepath=</url>
</repository> <repository>
<id>jahia</id>
<name>mvnrepository</name>
<url>http://maven.jahia.org/maven2</url>
</repository> </repositories> <dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>compile</scope>
</dependency> <dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2_2.11</artifactId>
<version>2.4.6</version>
<scope>test</scope>
</dependency>
</dependencies> <build>
<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> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

2.需要注意:先编译scala代码,再编译java代码(原因:如果java 有依赖scala 代码,正常编译会抛错:无法找到scala代码)

关于scala和java 在maven项目中混编的问题的更多相关文章

  1. Java项目和maven项目中如何获取&设置配置文件中的属性

    通常情况下,我们会在一些配置文件文件中配置一些属性.如: indexPath = E\:\\Tomcat_7.0\\webapps\\ipost_stage\\lucene\\index imgUpl ...

  2. maven项目中的报错问题——Dynamic Web Module 3.0 requires Java 1.6 or newer.

    转自:http://www.cnblogs.com/beppezhang/p/5919221.html maven项目中的报错问题——Dynamic Web Module 3.0 requires J ...

  3. Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图(转载)

    Intellij IDEA 中如何查看maven项目中所有jar包的依赖关系图 2017年04月05日 10:53:13 李学凯 阅读数:104997更多 所属专栏: Intellij Idea   ...

  4. IDEA的maven项目中 静态文件编译的问题

    IDEA的maven项目中,默认源代码目录下的xml等资源文件并不会在编译的时候一块打包进classes文件夹,而是直接舍弃掉. 如果使用的是Eclipse,Eclipse的src目录下的xml等资源 ...

  5. IDEA的maven项目中静态文件编译的路径问题(未测试)

    转自:http://www.cnblogs.com/signheart/p/6625126.html IDEA的maven项目中,默认源代码目录下的xml等资源文件并不会在编译的时候一块打包进clas ...

  6. Maven项目中Spring整合Mybatis

    Maven项目中Spring整合Mybatis 添加jar包依赖 spring需要的jar包依赖 <dependency> <groupId>org.springframewo ...

  7. maven项目中没有resource文件夹的问题

    之前使用eclipse创建maven项目,文件夹都是建好的,这几次创建,都没有resource文件夹,需要手动创建resource. 现象描述 在eclipse中,创建maven项目有两种方式: 一种 ...

  8. Maven项目中使用JUnit进行单元测试

    1.打开maven项目中的pom.xml,添加JUnit 的jar包 2.在src/test/java下右键新建JUnit Test Cast

  9. 如何在maven项目中使用spring

    今天开始在maven项目下加入spring. 边学习边截图. 在这个过程中我新建了一个hellospring的项目.于是乎从这个项目出发开始研究如何在maven项目中使用spring.鉴于网上的学习资 ...

随机推荐

  1. Entityframework 伪CodeFirst开发模式应用于Sqlite数据库

    因为最近没有时间深入的研究EntityFramework的内部机制,所以具体的实现并不十分了解.微软最初的初衷是开发出一套通用的数据库访问逻辑,实现对Dal数据访问层的高度封装,其中就用到了工厂模式和 ...

  2. [C++空间分配]new运算符、operator new、placement new的区别于联系

    先科普一下: 1. new的执行过程: (1)通过operator new申请内存 (2)使用placement new调用构造函数(内置类型忽略此步) (3)返回内存指针 2. new和malloc ...

  3. js操作cookie,js判断浏览器属性,

    在默认情况下,只有设置cookie的网页才能读取该cookie.如果想让一个页面读取另一个页面设置的cookie,必须设置cookie的路径. http://www.jb51.net/article/ ...

  4. 在linux中限制用户ftp访问权限

    1.环境:redhat linux企业版4.ftp为vsftp.被限制用户名为aaa.被限制路径为/bbb.2.建用户:在root用户下,相继进行如下操作       adduser aaa      ...

  5. Java中的String,StringBuffer,StringBuilder详解与区别

    1.String Java中string类是不可变的,其中在声明的源代码中用的final,所以只能声明一次.所以每次在明面上的改变其实是重新生成一个String对象,指针指向新的String对象.同时 ...

  6. 各种数据库的批量插入操作_Oracle

    最近工作中需要优化以前各种的Excel批量导入功能,目前将能优化的方面做个记录. 选用技术: 目前.Net可以访问Oracle常用的Dll,有三种: 微软自带的 System.Data.OracleC ...

  7. shell基础认识

    Shell 我们在终端下写命令Linux内核是看不懂的必须通过shell解释成内核可执行的代码 这就是shell(其实解释命令这只是它的一个功能模块,shell还可以用来进行程序设计) 有点类似win ...

  8. JavaScript装逼指南

    如何写JavaScript才能逼格更高呢?怎样才能组织JavaScript才能让别人一眼看出你不简单呢?是否很期待别人在看完你的代码之后感叹一句“原来还可以这样写”呢?下面列出一些在JavaScrip ...

  9. Android Studio常用小技巧

    1. Debug 模式查看变量的值: To quickly evaluate the value of any expression while debugging the program, hold ...

  10. JS的匿名函数和递归应用

    今天有项目需要用到JS的递归,开始按照php的实现方法,发现不行,后来只能使用arguments.callee. 简单的例子,如下 var act = 'if(num <= 1){return ...