error: 使用 openJDK17 构建时,无效的源发布版本:1.17

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

error: invalid source release: 1.17 whiling using openJDK17 to build

问题

我更新了我的Maven项目的maven.compiler.targetmaven.compiler.source,从1.81.17,并且我也升级了我的JDK到openjdk version "17.0.6" 2023-01-17

我确认我的Maven版本也正在使用JDK 17,通过运行mvn -v来验证。

Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /usr/local/Cellar/maven/3.9.0/libexec
Java version: 17.0.6, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.6/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.6.3", arch: "x86_64", family: "mac"

但我仍然看到这个错误 invalid source release: 1.17
有什么我应该检查的吗?

顺便说一句,如果我的maven.compiler.targetmaven.compiler.source都是1.8,并且使用JDK17进行编译,我就不会看到这个错误。

谢谢。

英文:

I updated the maven.compiler.target and maven.compiler.source of my maven project from both 1.8 to 1.17 and I also updated my JDK to openjdk version "17.0.6" 2023-01-17.

I confirm my maven version is also using jdk17 by running mvn -v.

Apache Maven 3.9.0 (9b58d2bad23a66be161c4664ef21ce219c2c8584)
Maven home: /usr/local/Cellar/maven/3.9.0/libexec
Java version: 17.0.6, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@17/17.0.6/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "12.6.3", arch: "x86_64", family: "mac"

But I am still seeing this error invalid source release: 1.17.
Is there anything I should check?

BTW, I do not see this error if my maven.compiler.target and maven.compiler.source are both 1.8 while using the JDK17 to compile.

Thank you.

答案1

得分: 3

Java的版本号在1.8版本之后发生了变化。新版本不再带有 1. 前缀。

所以您的版本必须是 17。

<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>

英文:

The versioning for java has changed after version 1.8. The newer versions are without 1.

So your version must be 17.

&lt;maven.compiler.target&gt;17&lt;/maven.compiler.target&gt;  
&lt;maven.compiler.source&gt;17&lt;/maven.compiler.source&gt;  

huangapple
  • 本文由 发表于 2023年3月8日 15:17:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670241.html
匿名

发表评论

匿名网友

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

确定