使用IDEA进行scala/java混合工程的构建
来源:互联网 发布:屏风专卖店淘宝网 编辑:程序博客网 时间:2024/06/09 06:39
构建scala/java混合工程,大致有2种方式:
方式一、
File ----》New Project ----》勾选Maven ----》 再勾选Create from archetype ----》选择 "org.scala-tools.archetypes:scala-archetype-simple"
这种方式构建混合工程较为简单,但是由于插件更新不及时,安装时的scala版本及jdk版本可能较小,需要与目标项目的版本做相应的适配。
如将默认scala2.7.0版本替换为2.10版本,将jvm-1.5版本替换为jvm-1.7。
方式二、
①、本机安装scala sdk
去scala官网 http://www.scala-lang.org/download 下载与操作系统对应的scala版本,安装。
②、Idea上Plugins搜索下载Scala插件,也可以下载离线安装包(点击打开链接),本地以disk方式安装。
务必注意在下载时,留意scala插件库中版本号与本机IEDA的版本对应关系。
③、与maven整合
编辑pom.xml,设置为如下内容:
<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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.balabala.mixed</groupId> <artifactId>mixed-scala-java-test</artifactId> <version>1.0-SNAPSHOT</version> <properties> <scala.version>2.10.0</scala.version> </properties> <repositories> <repository> <id>scala-tools.org</id> <name>Scala-Tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>scala-tools.org</id> <name>Scala-Tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </pluginRepository> </pluginRepositories> <dependencies> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>${scala.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.4</version> <scope>test</scope> </dependency> <dependency> <groupId>org.specs</groupId> <artifactId>specs</artifactId> <version>1.2.5</version> <scope>test</scope> </dependency> </dependencies> <build> <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <version>2.15.2</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> <configuration> <scalaVersion>${scala.version}</scalaVersion> <args> <arg>-target:jvm-1.8</arg> </args> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <downloadSources>true</downloadSources> <buildcommands> <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand> </buildcommands> <additionalProjectnatures> <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature> </additionalProjectnatures> <classpathContainers> <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer> </classpathContainers> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <configuration> <scalaVersion>${scala.version}</scalaVersion> </configuration> </plugin> </plugins> </reporting></project>
④、maven编译打包
直接使用mvn clean package会报错,因为默认只会打包java文件,需要使用如下命令替换之:
mvn clean scala:compile compile package
命令解释:
如③中的 maven-scala-plugin 配置,是其提供的对scala编译打包的插件命令,将先编译scala源码,再编译java源码,最后做package操作。
阅读全文
0 0
- 使用IDEA进行scala/java混合工程的构建
- IDEA 创建Scala和Java的混合项目
- 使用 IDEA 创建 Scala 工程
- idea使用maven构建java和scala项目开发spark
- 让maven正常编译scala、java代码混合的工程
- IDEA Java/Scala混合项目maven打包
- IDEA Java/Scala混合项目maven打包
- IDEA Java/Scala混合项目maven打包
- 使用SBT构建Scala开发的Android工程
- 使用IntellJ idea以maven作为项目构建的方式创建java工程
- IntelliJ IDEA构建基于maven的spark+hbase工程(scala语言)
- idea用maven构建java+scala项目
- Intellij idea使用Maven管理Scala工程
- idea使用-创建scala项目工程
- IDEA构建scala的maven项目
- 用IDEA创建sbt的Scala工程
- IDEA使用maven的进行mybatis的逆向工程
- idea 使用sbt构建工程时错误unresolved dependency: org.scala-sbt#sbt;0.13.8: not found
- Python3 安装 pip3 以及 scrapy、numpy、itchat
- 接口编写、调用及测试简介
- Windows核心编程->文件操作
- 解决office word 2016 、2013等一直正在启动的问题
- 463. Island Perimeter
- 使用IDEA进行scala/java混合工程的构建
- awk基于固定的字符抽取双引号中的数据
- Qt之进程间通信(共享内存)
- zookeeper的应用和原理
- HBase写性能优化策略
- 区块链是什么
- redis 检查key expire事件
- 利用栈数据结构彻底搞定走迷宫案例解析(并非最短路径)
- 从git上拉取代码后使用 project clean命令也build不通过