<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.8.4.0</version>
<executions>
<!--package时执行spotbugs检测-->
<execution>
<id>spotbugs-check</id>
<phase>package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<!--校验开关-->
<failOnError>true</failOnError>
<!--校验级别-->
<xmlOutput>true</xmlOutput>
<htmlOutput>true</htmlOutput>
</configuration>
<dependencies>
<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>4.8.4</version>
</dependency>
</dependencies>
</plugin>
如果打包失败,有不符合代码规范处,可以看target下的spotbugs.html
,此html页面不好看,所以推荐使用maven spotbugs:GUI
查看详细页面,spotBugs提供的GUI很直观,类似于sonar页面