org.codehaus.mojo:缺少 findbugs-maven-plugin

org.codehaus.mojo:findbugs-maven-plugin is missing

我需要在新服务器上部署 mvn 项目,我想使用 findbug 插件 运行 mvn install:

时出现以下错误
 myServer:~/myrepository$ mvn install
    [INFO] Scanning for projects...
    [WARNING]
    [WARNING] Some problems were encountered while building the effective model for com.example:simple-app:war:0.0.1-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:findbugs-maven-plugin is missing. @ line 56, column 12
    [WARNING]
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING]
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

这是我的pom.xml

        <build>
            <plugins>
                    <plugin>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>findbugs-maven-plugin</artifactId>
                    </plugin>
            </plugins>
    </build>

    <reporting>
            <plugins>
                    <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>findbugs-maven-plugin</artifactId>
                            <version>3.0.5-SNAPSHOT</version>
                            <configuration>
                                    <xmlOutput>true</xmlOutput>
                                    <!-- Optional directory to put findbugs xdoc xml report -->
                                    <xmlOutputDirectory>target/site</xmlOutputDirectory>
                            </configuration>
                    </plugin>
            </plugins>
    </reporting>

如果有任何想法,我将不胜感激。

正如@Tunaki 在评论中指出的那样。日志明确显示 [WARNING],接下来的消息非常清楚。

[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:findbugs-maven-plugin is missing.


此外,根据您的评论和现有 pom.xml,您应按如下方式修改构建:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.4.2.RELEASE</version> <!-- using latest from maven central, feel free to use any specific -->
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>3.0.4</version> <!-- using latest from maven central, feel free to use any specific -->
        </plugin>
     </plugins>
</build>

并报告给

<reporting>
    <plugins>
         <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>findbugs-maven-plugin</artifactId>
              <version>3.0.4</version> <!--have modified this -->
              <configuration>
                  <xmlOutput>true</xmlOutput>
                  <!-- Optional directory to put findbugs xdoc xml report -->
                  <xmlOutputDirectory>target/site</xmlOutputDirectory>
              </configuration>
         </plugin>
    </plugins>
</reporting>

除了插件语句之外,我还通过添加工件作为依赖项解决了这个问题。 maven 分析的错误消失了。我认为这没有任何副作用。

    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>findbugs-maven-plugin</artifactId>
        <version>n.n.n</version>
    </dependency>