对于maven的一些插件来说,它们也都有着自己的依赖关系,建议把依赖的包和插件也写到pom里,如果你不写,在mvn时,它会自己去下载,如图:
如果你希望生成spotbug文档,你可以添加下面的几个插件,注意它们的版本号,需要对应清楚
<plugins>
<!-- 代码检查 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.29</version>
</dependency>
</dependencies>
<configuration>
<configLocation>/google_checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
</configuration>
</plugin>
<!-- bug检查 -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.0.4</version>
<executions>
<execution>
<id>check</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
</plugin>
<!-- mvn site时使用 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
</configuration>
</plugin>
</plugins>
</build>
然后使用下面命令去生成文档
mvn site
生成需要一些时间,之后的结果如图
原文:https://www.cnblogs.com/lori/p/13602605.html