對于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.uj5u.com/houduan/17419.html
標籤:Java
上一篇:JVM 垃圾收集演算法 標記-清楚、標記-復制、標記-整理
下一篇:JAVA 例外
