Maven JDK Version: *.*.* is not in the allowed range

使用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.pluginsgroupId>
       <artifactId>maven-enforcer-pluginartifactId>
       <version>3.0.0-M3version>
       <executions>
         <execution>
           <id>enforce-javaid>
           <goals>
             <goal>enforcegoal>
           goals>
           <configuration>
             <rules>
               <requireJavaVersion>
                 <version>1.6.0version>
               requireJavaVersion>
             rules>    
           configuration>
         execution>
       executions>
     plugin>
   plugins>
 build>

然后运行mvn clean,在运行mvn install即可。

一个这么简单的错误搞了我两个小时,吐血…
查看报错栈让我以为是pom导包有问题,调试方向反了…

你可能感兴趣的:(问题解决)