您的位置:首页 > 其它

maven Error:No compiler is provided in this environment.

2014-11-30 20:29 459 查看
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 问题
maven编译项目时出错,提示信息如下:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project springside-core: Compilation failure[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [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/MojoFailureException 解决方案:下载java jdk,并安装java jdk。下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

在eclipse的菜单中,进入 Window > Preferences > Java > Installed JREs > Execution Environments,选择JavaSE-1.6, 在右侧选择jdk.
然后在maven菜单中使用 “update project ...”.关键是这个点击工程的右键,升级当前的项目,否则项目上面有叉叉。
jdk是开发工具
jre是运行环境
编译用的都是jdk的resources嘛,开发时不能只有运行库,应该具备开发库,就是这个意思。

=====================================================================================
如果没有安装MAVEN插件,请点击1. 首先安装maven插件,进入eclipse的help->marketplace,在find框中输入“maven”,选择“maven integration for eclipse(juno and newer)”项的install按钮


2. 进入window->preferences窗口,选择java->Installed JREs,默认情况下只有eclipse一项,这里要通过add按钮增加jdk对对应的路径加进来,否则在编译的时候会报错:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?注意:No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?意思是说:你应该指定一个JDK,而不是一个JRE。显示的JRE HOME,但是需要的是完整的JDK。如果只指定JRE可以最小环境编译,但是否则MAVEN无法运行,或者保证MAVEN的运行。系统需要指定J2SE1.7的具体环境。



接着,进入Installed JREs的子项Execute Environment:在左侧选择JavaSE-1.6,右侧选择jdk


3. 在项目文件上单击右键,选择Maven->update project。


如果这个项目不是maven项目,则单击项目图标,现在configure->Convert to Maven project


4. 右键,选择Run As->Maven install,之后会开始下载编译过程中所需的文件


5. 之后,选择Maven Build,第一次运行会出现Run Configurations对话框,主要是在Goals框中输入要编译出的目标文件,Goals的选项包括:validate
initialize
generate-sources
process-sources
generate-resources
process-resources
compile 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

如果goals不输入内容,编译的时候会提示[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format.....进一步的细节可以参考 http://gavin-chen.iteye.com/blog/336607
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐