使用mvn install
时报错:
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (*-*-*) on project manager:
Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message: Detected JDK Version: 13.0.2 is not in the allowed range [1.8.0-40,1.9),[9.0,12.0).
网上找了两个解决办法:
- Maven编译错误记录:Some Enforcer rules have failed
- Detected JDK Version: 1.6.0-24 is not in the allowed range 1.7
但我在修改了JDK的版本后,还是没用。
最后还是Maven官方文档给力:Require Java Version
修改项目根目录下的pom.xml
文件:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.6.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
然后运行mvn clean
,在运行mvn install
即可。
一个这么简单的错误搞了我两个小时,吐血…
查看报错栈让我以为是pom
导包有问题,调试方向反了…