Maven构建中的Java编译错误:maven-compiler-plugin

huangapple go评论73阅读模式
英文:

Maven Java error compiling on build: maven-compiler-plugin

问题

当我尝试运行Maven构建时,它总是报BUILD FAILURE错误。

无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) 于项目 testJPA: 编译致命错误无效的目标版本11 -> [帮助 1]

我已经尝试了以下操作:

  • 删除 .m2 文件夹
  • 重新安装 Eclipse
  • 在 pom.xml 上设置可执行权限
  • 将构建选项设置为 clean
> java -version
java 版本 "1.8.0_261"

> echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_211

pom.xml

<plugin>
	<inherited>true</inherited>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.8.0</version>
	<configuration>
		<source>11</source>
		<target>11</target>
		<encoding>UTF-8</encoding>
		<showWarnings>true</showWarnings>
		<showDeprecation>true</showDeprecation>
	</configuration>
</plugin>

以上方法都没有奏效。有什么猜测吗?

英文:

When I try to run as maven build it always give BUILD FAILURE.

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project testJPA: Fatal error compiling: invalid target release: 11 -> [Help 1]

I already tried the following things:

  • remove .m2 folder
  • reinstall eclipse
  • set executable on pom.xml
  • set build option to clean
> java -version
java version "1.8.0_261"

> echo %JAVA_HOME%
C:\Program Files\Java\jdk1.8.0_211

pom.xml

<plugin>
	<inherited>true</inherited>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-compiler-plugin</artifactId>
	<version>3.8.0</version>
	<configuration>
		<source>11</source>
		<target>11</target>
		<encoding>UTF-8</encoding>
		<showWarnings>true</showWarnings>
		<showDeprecation>true</showDeprecation>
	</configuration>
</plugin>

None of them worked. Any guesses?

答案1

得分: 0

我找到了一个解决方案。

我安装了 JDK 11,并在 Window > Preferences > Java > Installed JREs > Add > jdk-11.0.9 进行了设置。

下载链接:https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

英文:

I managed to find a solution.

I installed JDK 11 and set it at Window > Preferences > Java > Installed JREs > Add > jdk-11.0.9

Downloaded at: https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

huangapple
  • 本文由 发表于 2020年10月24日 07:56:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64508655.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定