构建 Maven 项目:给出编译错误

我是 Java/Maven 的新手,我正在尝试构建一个 maven Spring Boot 项目,它在早期工作并且也成功地创建了 jar 包。但它突然停止工作并开始出现 Maven 编译错误。

我知道这与文件有关pom.xml。我的最佳猜测:此文件中的某些更改导致它失败。

错误


[INFO] ------------------------------------------------------------------------

[INFO] BUILD FAILURE

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 0.905 s

[INFO] Finished at: 2019-08-08T01:52:48+05:30

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project springboot-helloworld: Fatal error compiling: error: invalid target release: 12.0.1 -> [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/MojoExecutionException

Java版


java version "12.0.1" 2019-04-16

Java(TM) SE Runtime Environment (build 12.0.1+12)

Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)

我已经尝试了很多类似问题的 stackoverflow 答案,但仍然无法解决这个问题。


LEATH
浏览 113回答 2
2回答

小唯快跑啊

如果您使用的是 Java 12,请将以下内容添加到 Maven pom.xml。<plugin>&nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; <artifactId>maven-compiler-plugin</artifactId>&nbsp; &nbsp; <version>3.8.0</version>&nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; <release>12</release>&nbsp; &nbsp; </configuration></plugin>

慕虎7371278

属性maven.compiler.source和maven.compiler.target在默认生命周期中被许多插件使用,你必须尝试:<properties>        <maven.compiler.source>12</maven.compiler.source>        <maven.compiler.target>12</maven.compiler.target></properties>但是如果你只想覆盖这个目标,你可以像这样配置它:<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-compiler-plugin</artifactId>    <version>3.8.0</version>    <configuration>        <release>12</release>    </configuration></plugin>由于您是 Java 的新手,请记住新的版本控制模式,因此即使您安装了 12 版本,如果没有打算使用新的语言功能,您也可以将 11 LTS 目标作为目标。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java