maven-enforcer-plugin误报requirejavaverion

发布于 2025-01-23 02:22:22 字数 1471 浏览 0 评论 0原文

我是一个项目的新手,该项目正在使用 maven-enforcer-plugin

插件(版本3.0.0)被配置为需要Java 11,

<requireJavaVersion>
  <version>11</version>
</requireJavaVersion>

的路径上也有JDK 11

$ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

我 Java 11是必需的,

[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-versions) @ checkstyle ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.8.0-261 is not in the allowed range 11.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.231 s
[INFO] Finished at: 2022-04-21T18:04:07-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (enforce-versions) on project checkstyle: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. 
-> [Help 1]

为什么我要遇到此错误?

I'm new to a project and the project is using the maven-enforcer-plugin.

The plugin (version 3.0.0) is configured to require Java 11

<requireJavaVersion>
  <version>11</version>
</requireJavaVersion>

I also have jdk 11 on my path

$ java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

However, when I run mvn clean verify I get a failure saying that I'm on Java 8 when Java 11 is required

[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-versions) @ checkstyle ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.8.0-261 is not in the allowed range 11.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.231 s
[INFO] Finished at: 2022-04-21T18:04:07-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (enforce-versions) on project checkstyle: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. 
-> [Help 1]

Why would I be getting this error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2025-01-30 02:22:22

就我而言,我的问题是我的用户java_path变量已配置为Java 8,但是我的系统java_path已配置为11。 > java_path 。

In my case, my issue was that my user JAVA_PATH variable was configured to Java 8, but my system JAVA_PATH was configured for 11. It looks like maven uses the user's JAVA_PATH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文