亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

構建 Maven 項目:給出編譯錯誤

構建 Maven 項目:給出編譯錯誤

LEATH 2023-05-24 16:09:20
我是 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/MojoExecutionExceptionJava版java version "12.0.1" 2019-04-16Java(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 答案,但仍然無法解決這個問題。
查看完整描述

2 回答

?
小唯快跑啊

TA貢獻1863條經驗 獲得超2個贊

如果您使用的是 Java 12,請將以下內容添加到 Maven pom.xml。


<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-compiler-plugin</artifactId>

    <version>3.8.0</version>

    <configuration>

        <release>12</release>

    </configuration>

</plugin>


查看完整回答
反對 回復 2023-05-24
?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

屬性maven.compiler.sourcemaven.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 目標作為目標。



查看完整回答
反對 回復 2023-05-24
  • 2 回答
  • 0 關注
  • 183 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號