简体   繁体   English

Maven Spring启动编译错误?

[英]Maven Spring boot compilation error?

I am trying to compile a spring boot project with mvn package command but I am getting this error. 我正在尝试使用mvn package命令编译spring boot项目,但出现此错误。 I believe I have the JDK 1.7_55 installed. 我相信我已经安装了JDK 1.7_55。

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.144s
[INFO] Finished at: Fri May 16 11:57:18 EST 2014
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project m
yproject: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Here is the output of the javac. 这是javac的输出。

testspring>javac -version
javac 1.7.0_55

And here is the output of maven version. 这是Maven版本的输出。

..\testspring>mvn -v
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-20     00:51:28+1100)
Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.0.5\bin\..
Java version: 1.7.0_55, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jre7
Default locale: en_AU, platform encoding: Cp1252
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"

try the following 尝试以下

Go to

Windows -> Preferences -> Java -> Installed JREs

And check whether it is pointing to your JDK path , if not, click on edit button and put the path you configured your JAVA_HOME enviroment. 并检查它是否指向您的JDK path ,如果不是,请单击“ edit按钮,然后将路径配置为您的JAVA_HOME环境。

And

Go to

Window > Preferences > Java > Installed JREs > Execution Environments

Select JavaSE-1.6 or your required version , click the jdk checkbox on the right. 选择JavaSE-1.6 or your required version ,单击右侧的jdk checkbox

Then right click on your project in eclipse and select Mavan -> “update project configuration” 然后在eclipse中右键单击您的项目,然后选择Mavan -> “update project configuration”

Try setting your JAVA_HOME to the location where you have your JDK installed, for example: 尝试将JAVA_HOME为安装JDK的位置,例如:

export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Or with newer JDK: 或使用更新的JDK:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/

I got the issue because my java is referred to JRE rather than JDk . 我遇到了这个问题,因为我的java被引用为JRE而不是JDk

I was using spring tool suite. 我正在使用弹簧工具套件。

go to windows->preferences->Java->installedJre's and verify if it's pointed to JRE or JDK 转到windows->preferences->Java->installedJre's并验证它是否指向JRE或JDK

Right click on your project-> goto properties ->Select java build path -> switch to Libraries -> there you have to change jre to jdk 右键单击您的项目->转到属性->选择Java构建路径->切换到库->在那您必须将jre更改为jdk

在此处输入图片说明

I think this will solve your problem. 我认为这可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM