简体   繁体   中英

Maven Spring boot compilation error?

I am trying to compile a spring boot project with mvn package command but I am getting this error. I believe I have the JDK 1.7_55 installed.

[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.

testspring>javac -version
javac 1.7.0_55

And here is the output of maven version.

..\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.

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.

Then right click on your project in eclipse and select Mavan -> “update project configuration”

Try setting your JAVA_HOME to the location where you have your JDK installed, for example:

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

Or with newer 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 .

I was using spring tool suite.

go to windows->preferences->Java->installedJre's and verify if it's pointed to JRE or JDK

Right click on your project-> goto properties ->Select java build path -> switch to Libraries -> there you have to change jre to jdk

在此处输入图片说明

I think this will solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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