Java&Scala混合编程
来源:互联网 发布:电气专业单词软件下载 编辑:程序博客网 时间:2024/06/05 04:51
1. mvn 创建一个普通的java工程后,添加如下信息:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.jerry</groupId> <artifactId>mix-test</artifactId> <version>1.0-SNAPSHOT</version> <properties> <jackson.version>2.4.2</jackson.version> <scala.version>2.11.1</scala.version> <slf4j.version>1.7.7</slf4j.version> <scala.maven.version>2.11.1</scala.maven.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <defaultGoal>package</defaultGoal> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> <resource> <directory>src/test/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> <executions> <execution> <goals> <goal>copy-resources</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.0</version> <configuration> <recompileMode>incremental</recompileMode> <args> <arg>-target:jvm-1.7</arg> </args> <javacArgs> <javacArg>-source</javacArg> <javacArg>1.7</javacArg> <javacArg>-target</javacArg> <javacArg>1.7</javacArg> </javacArgs> </configuration> <executions> <execution> <id>scala-compile</id> <phase>process-resources</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>scala-test-compile</id> <phase>process-test-resources</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId> net.alchim31.maven </groupId> <artifactId> scala-maven-plugin </artifactId> <versionRange> [3.1.6,) </versionRange> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </pluginExecutionFilter> <action> <ignore></ignore> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build></project>
2. 在src/main/下,创建 scala 目录
src/main/java
src/main/scala
3. demo:
Java class:
//package mix.java.scala; public class GreetingInJava { public void greet() { System.out.println("Hello World!"); }}
Scala class:
class GreetingInScala { def greet: Unit = { val delegate: GreetingInJava = new GreetingInJava delegate.greet }}
public class Bootstrap { public static void main(String[] args) { GreetingInScala scala = new GreetingInScala(); scala.greet(); }}
0 0
- Java&Scala混合编程
- Eclipse下Java+Scala混合编程的Maven项目
- maven混合编译java&scala
- scala 和Java混合编译
- Scala java maven 混合开发 pom配置
- IDEA Java/Scala混合项目maven打包
- IDEA Java/Scala混合项目maven打包
- IDEA Java/Scala混合项目maven打包
- Maven项目 混合编译Java和Scala
- C++&Java混合编程
- java c++混合编程
- JAVA调用Scala编程
- Java混合编程资源小结
- C++与Java混合编程
- C++ 与 Java 混合编程
- C++与Java混合编程
- C++与Java混合编程
- C++与Java混合编程
- Android控件之ViewStub的使用技巧
- AspNet WebApi 中应用fo-dicom抛出异常:No codec registered for tranfer syntax:
- 数据库性能优化二:数据库表优化
- PSSM特征-从生成到处理
- Android TextView内容过长加省略号
- Java&Scala混合编程
- Qt中main函数详解
- 【Hdu】1080 Human Gene Functions
- 数据库性能优化三:程序操作优化
- DicomIoException: Requested 132 bytes past end of fixed length stream.
- bootstrap-table(三)
- 设置mysql中自增列的初始值和增加步长
- Unix网络编程中第一个例子出现connect error: Connection refused
- Material Designer的低版本兼容实现(五)—— ActivityOptionsCompat