Maven PMD 插件带有一个默认的 PMD 版本:对于maven-pmd-plugin 3.16.0,默认使用PMD 6.42.0。
鉴于更新的 PMD 版本是兼容的,您可以覆盖 PMD 版本,Maven 插件将使用并受益于最新的错误修复和增强功能:
<project> <properties> <pmdVersion>...choose your version...</pmdVersion> </properties> ... <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-pmd-plugin</artifactId> <version>3.16.0</version> <dependencies> <dependency> <groupId>net.sourceforge.pmd</groupId> <artifactId>pmd-core</artifactId> <version>${pmdVersion}</version> </dependency> <dependency> <groupId>net.sourceforge.pmd</groupId> <artifactId>pmd-java</artifactId> <version>${pmdVersion}</version> </dependency> <dependency> <groupId>net.sourceforge.pmd</groupId> <artifactId>pmd-javascript</artifactId> <version>${pmdVersion}</version> </dependency> <dependency> <groupId>net.sourceforge.pmd</groupId> <artifactId>pmd-jsp</artifactId> <version>${pmdVersion}</version> </dependency> </dependencies> </plugin> </plugins> </pluginManagement> </build> ... </project>