치명적 오류 컴파일 : 유효하지 않은 대상 릴리스 : 1.8-> [도움말 1]
잘못된 대상 릴리스 : 1.7 에 게시 된 것과 비슷한 문제가 있지만 블로그를 따른 후에도 여전히 문제가 해결되지 않습니다.
hm_app 프로젝트에서 목표 org.apache.maven.plugins : maven-compiler-plugin : 3.1 : compile (기본 컴파일)을 실행하지 못했습니다 : 치명적 오류 컴파일 : 잘못된 대상 릴리스 : 1.8-> [도움말 1]
이 문제에 직면했을 때 튜토리얼 로 따르고있었습니다 .
abt java & mvn
C:\mvn>echo %JAVA_HOME%
C:\mvn>echo %JRE_HOME%
C:\mvn>echo %MAVEN_HOME% yields
출력
C:\Program Files\Java\jdk1.7.0_51
C:\Program Files\Java\jre7
C:\apache-maven-3.0.4
%JAVA_HOME
jdk 1.7로 설정 했지만 1.8을 사용하여 컴파일하려고합니다. jdk 1.8을 설치 %JAVA_HOME
하고 그것을 가리 키거나 대상 릴리스를 1.7로 떨어 뜨려 놓으십시오.
유효하지 않은 대상 릴리스 : 1.8
대상 릴리스는 jdk 버전을 나타냅니다.
플러그인에 값을 넣으십시오.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
오류는 사용되었습니다 :
<source>${java.version}</source>
<target>${java.version}</target>
필자의 경우 maven "Run configuration"에서 잘못된 JRE (1.7)를 사용하고있었습니다. 있는지 확인하는 실행 -> 실행 구성 -> (탭) JRE는 일부 jdk1.8.x. 할 수
JDK가 1.7을 가리키고 JRE가 1.8을 가리키면서 문제가 해결되었습니다. 명령 프롬프트에서 입력을 확인하십시오.
java -version
과
javac -version.
둘 다 같아야합니다.
이클립스에서 내 문제를 해결하는 방법은 다음과 같습니다.
Run as maven build를 사용하여 maven을 통해 다시 빌드하십시오.
더 이상 유효하지 않은 대상 오류를 표시하지 않아야합니다.
참고 : 터미널에서 다른 변수를 설정하거나 변경할 필요가 없었습니다. 도움이 되었기를 바랍니다.
그것을 .profile에 넣으면 동적으로 $JAVA_HOME
export JAVA_HOME=$(/usr/libexec/java_home)
Close your shell afterwards, open a new one and test with
echo $JAVA_HOME
It should display something like
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
If not, remove any other assignments of JAVA_HOME in your startup scripts. Remember, that these startup scripts start with a .
so they are hidden and won't be included when using *
wildcard, e.g. if you want to grep all files of your home directory, you need to:
grep -s JAVA_HOME ~/.* --exclude=.bash_history
The problem I was facing was that I was able to make a maven build from the command prompt but not from Eclipse.What worked for me in eclipse is that I changed the run configuration to point to JRE folder inside of JDK rather than leaving it in JDK folder only as per the standard.This solution may work for you as well but try this if and only if all the java paths are correct, java and javac are showing the same version as present in the target of pom.xml.
This question wasn't asking explicitly about Docker, but I received the same error when I had a pom.xml file that was targeting 1.9...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
</properties>
... but then tried to run tests against a Docker container by specifying "maven" by itself.
docker run -t --rm -v m2_repository:/root/.m2/repository -v $(pwd):/work -w /work maven mvn -e test
For me, the fix was to target the exact version I needed.
docker run -t --rm -v m2_repository:/root/.m2/repository -v $(pwd):/work -w /work maven:3.5.2-jdk-9 mvn test
(You can learn more here.)
I faced this issue deploying on Dokku, for some reason it was choosing JDK 1.7
Creating a system.properties
file and setting java.runtime.version=1.8
solved the issue. Dokku now uses Java version 8. Choosing a JDK on Heroku
I Never had to do it before...
On Windows machine you can temporarily set Java version.
For example, to change the version to Java 8, run this command on cmd
:
set JAVA_HOME=C:\\...\jdk1.8.0_65
Do a force Maven Update which will bring the compatible 1.8 Jar Versions and then while building, update the JRE Versions in Execute environment to 1.8 from Run Configurations and hit RUN
If you are using Eclipse IDE then go inside Window menu and select preferences and there you search for installed JREs and select the JRE you need to build the project
As mentioned by Camila Macedo - you have to explicitly point the java version for compiler-plugin. For spring boot you can do that by next property:
<properties>
<java.version>1.8</java.version>
<maven.compiler.release>8</maven.compiler.release>
</properties>
What worked in my case is this:
I opened the pom.xml
and replaced the one of the plug-ins as below.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Before I edited the source and target tags both had 1.8
, I changed that to 1.7
and it worked.
참고 URL : https://stackoverflow.com/questions/28291691/fatal-error-compiling-invalid-target-release-1-8-help-1
'IT' 카테고리의 다른 글
JavaScript 변수가 정의되어 있지 않은지 확인하는 방법은 무엇입니까? (0) | 2020.06.09 |
---|---|
numpy 배열의 목록 목록 (0) | 2020.06.09 |
특정 버전을 어떻게 연결할 수 있습니까? (0) | 2020.06.09 |
PowerShell에서 배열 객체를 문자열로 어떻게 변환합니까? (0) | 2020.06.09 |
저장소에서 업데이트 된 종속성을 확인한 Maven (0) | 2020.06.09 |