Maven 工程添加 findbugs 插件

pom.xml 添加插件plugin

<build>
    <plugins>
        
        <plugin>
            <groupId>org.codehaus.mojogroupId>
            <artifactId>findbugs-maven-pluginartifactId>
            <version>3.0.4version>
            <configuration>
                
                <effort>Loweffort>
                
                <threshold>Mediumthreshold>
                <failOnError>truefailOnError>
                <includeTests>trueincludeTests>
                
                <excludeFilterFile>findbugs/findbugs-exclude-filter.xmlexcludeFilterFile>
            configuration> 
            <executions>
                <execution>
                    <id>run-findbugsid>
                    
                    <phase>packagephase>
                    <goals>
                        <goal>checkgoal>
                    goals>
                execution>
            executions>
        plugin>
    plugins>
build>

findbugs-exclude-filter.xml 内容示例


<FindBugsFilter>
    <Match>
        <Class name="~.*\.(model|entity|vo)\..*" />
        <Method name="~(get.*|set.*)" />
        
        <Bug code="EI,EI2" />
    Match>
    <Match>
        <Class name="~.*\.Authorization" />
        <Bug code="EI,EI2" />
    Match>
FindBugsFilter>

关于 filter 的其他说明可以查看:http://findbugs.sourceforge.net/manual/filter.html

经常使用的2个命令:
mvn clean compile findbugs:findbugs
mvn findbugs:gui

你可能感兴趣的:(Maven 工程添加 findbugs 插件)