我希望使用maven-enforcer 插件的bannedDependencies规则来强制执行特定的Spring 版本(3.1.2) 。
这是配置执行器插件以实现这一目标的正确方法吗?
<configuration>
<rules>
<bannedDependencies>
<searchTransitive>true</searchTransitive>
<excludes>
<exclude>org.springframework</exclude>
</excludes>
<includes>
<include>org.springframework:*:3.1.2</include>
</includes>
</bannedDependencies>
</rules>
<fail>true</fail>
<failFast>true</failFast>
<ignoreCache>true</ignoreCache>
</configuration>
以上似乎可行,并且mvn enforcer:enforce
在命令行上突出显示 v3.1.0 或 org.springframework:spring-oxm 被作为传递依赖项引入。
似乎有人可能想要使用dependencyConvergence规则,但它突出了许多依赖错误,这些错误被maven自动排除为“冲突”。
这是一个包含更多上下文的片段:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin}</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<bannedDependencies>
<searchTransitive>true</searchTransitive>
<excludes>
<exclude>org.springframework</exclude>
<exclude>org.springframework.security</exclude>
<exclude>org.slf4j</exclude>
</excludes>
<includes>
<include>org.springframework:*:${spring.version}</include>
<include>org.springframework.security:*:${spring-security.version}</include>
<include>org.slf4j:*:${slf4j.version}</include>
</includes>
</bannedDependencies>
<requireJavaVersion>
<version>${enforce.jdk.version}</version>
</requireJavaVersion>
</rules>
<fail>true</fail>
<failFast>true</failFast>
<ignoreCache>true</ignoreCache>
</configuration>
</plugin>
.....
</plugins>