我在执行mvn versions:display-plugin-updates
时遇到以下错误。基于this discussion,该问题已在2.6中修复,但我使用的是2.7(尝试使用2.6,但未成功)。
[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain maven-enforcer-plugin to
[ERROR] force the Maven version which is needed to build this project.
[ERROR] See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[ERROR] Using the minimum version of Maven: 3.0.5
这是我的<pluginManager>
插件:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.5.4</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
</plugins>
</pluginManagement>
答案 0 :(得分:1)
即使给定插件具有pluginManagement
,您仍需要在pom的build
-> plugins
部分中声明该插件,配置才能生效。而某些插件,例如maven-compiler-plugin
默认添加到项目中,maven-enforcer-plugin
显然不是这种情况(如您的实验所示)。
我不确定是否有不需要显式添加的插件列表,但是我认为它是最常见的插件,例如maven-surefire-plugin和maven-clean-plugin。