我按照spotbugs.readthedocs.io的指示进行操作。将此部分添加到pom.xml
.
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3</version>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>3.1.3</version>
</dependency>
</dependencies>
</plugin>
然后我跑了mvn spotbugs:spotbugs
,它生成了projectDir/target/spotbugsXml.xml
. 然后我跑了mvn spotbugs:check
它输出
[INFO] --- spotbugs-maven-plugin:3.1.3:check (default-cli) @ my-project ---
[INFO] BugInstance size is 0
[INFO] Error size is 0
[INFO] No errors/warnings found
[INFO] --------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------------------------
[INFO] Total time: 6.731 s
[INFO] Finished at: 2018-05-25T16:31:35-04:00
[INFO] --------------------------------------------------------------------
更新 - 我必须将它添加到项目/报告/插件部分以及构建部分。现在,当我运行它时,它会在其中mvn site
生成一个包含 SpotBugs 的部分。Project Reports
target/site/index.html
<reporting>
<plugins>
<!-- SpotBugs -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.3</version>
</plugin>
</plugins>
</reporting>