maven-enforcer-plugin误报requirejavaverion
我是一个项目的新手,该项目正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我而言,我的问题是我的用户
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 systemJAVA_PATH
was configured for 11. It looks like maven uses the user'sJAVA_PATH
.