[Eclipse构建maven scala和java项目]

0 篇文章 0 订阅
0 篇文章 0 订阅

Eclipse构建maven scala项目

一、安装环境

操作系统:Windows 10

Eclipse版本:

JVM:1.8

Scala版本:2.11.0

二、插件安装

2.1 安装eclipse scala插件

eclipse marketplace中安装scala插件

 

在选项卡[Search]中输入scala,安装Scala IDE 4.7.x,根据提示一次安装即可。

 

 

2.2 安装m2e-scala插件

Installl New Software中安装m2e-scala插件

 

安装URLhttp://alchim31.free.fr/m2e-scala/update-site/

 

选择响应的插件安装即可

 

2.3 安装Maven工程模板

创建Maven工程

 

新建Archetype,因为maven默认没有。

Group Id: net.alchim31.maven

Artifact Id: scala-archetype-simple

Version:1.6

点击[Add Archetype],如下图所示:

 

选择刚刚添加的scala-archetype-simple这个模板就可以了。

 

 

三、编译设置

Scala项目Maven项目编译打包过程中,可能会出现的一些问题。以下是本机机器上编译出现的一些问题:

3.1 问题一

[INFO] Scanning for projects...

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.111s

[INFO] Finished at: Tue Apr 24 09:20:52 CST 2018

[INFO] Final Memory: 6M/184M

[INFO] ------------------------------------------------------------------------

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

 

解决方法:

pom.xml文件中添加<defaultGoal>install</defaultGoal>如下图所示。

 

3.2 问题二

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building mvnscala 1.0.0-RELEASE

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mvnscala ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory G:\Study\workspace\scala\mvnscala\src\main\resources

[INFO]

[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ mvnscala ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- scala-maven-plugin:3.2.0:compile (default) @ mvnscala ---

[INFO] G:\Study\workspace\scala\mvnscala\src\main\scala:-1: info: compiling

[INFO] Compiling 1 source files to G:\Study\workspace\scala\mvnscala\target\classes at 1524533443969

[ERROR] scalac error: bad option: '-make:transitive'

[INFO]   scalac -help  gives more information

[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.758s

[INFO] Finished at: Tue Apr 24 09:30:44 CST 2018

[INFO] Final Memory: 11M/232M

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.0:compile (default) on project mvnscala: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

 

解决方法:

根本原因是mvn clean package默认只处理java源代码的编译、打包,而对scala进行处理,所以编译时失败。

Maven编译的窗口中添加:clean scala:compile compile package,如下图所示:

 

最后的编译结果成功:

 

 

四、运行测试

 

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值