java Maven FindBugs 插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/504368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:40:55  来源:igfitidea点击:

Maven FindBugs plugin

javamaven-2maven-pluginfindbugs

提问by Etam

You have usage: findbugs-maven-plugin

你有用法:findbugs-maven-plugin

<project>
  [...]
  <reporting>
    [...]
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>findbugs-maven-plugin</artifactId>
      <version>1.2.1</version>
      <configuration>
        <xmlOutput>true|false</xmlOutput>
        <xmlOutputDirectory>directory location of findbugs xdoc xml report</xmlOutputDirectory>
        <threshold>High|Normal|Low|Exp|Ignore</threshold>
        <effort>Min|Default|Max</effort>
        <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
        <includeFilterFile>findbugs-include.xml</includeFilterFile>
        <visitors>FindDeadLocalStores,UnreadFields</visitors>
        <omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors>
        <onlyAnalyze>org.codehaus.mojo.findbugs.*</onlyAnalyze>
        <pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList>
        <debug>true|false</debug>
        <relaxed>true|false</relaxed>
        <findbugsXmlOutput>true|false</findbugsXmlOutput>
        <findbugsXmlOutputDirectory>directory location of findbugs legact xml format report</findbugsXmlOutputDirectory>
      </configuration>
    </plugin>
    [...]
  </reporting>
  [...]
</project>

But once:

但是有一次:

mvn site

I get:

我得到:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.codehaus.mojo
ArtifactId: findbugs-maven-plugin
Version: 1.2.1

Reason: Unable to download the artifact from any repository

  org.codehaus.mojo:findbugs-maven-plugin:pom:1.2.1

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)

Do you know why? What should I do?

你知道为什么吗?我该怎么办?

回答by Rob Di Marco

Looking at the repository, your version should be 1.2, not 1.2.1

查看存储库,您的版本应该是 1.2,而不是 1.2.1

Also, your configuration is wrong, you need to choose some of the options. So it should look like:

另外,你的配置是错误的,你需要选择一些选项。所以它应该看起来像:

    <plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>findbugs-maven-plugin</artifactId>
  <version>1.2</version>
  <configuration>
    <threshold>High</threshold>
    <effort>Default</effort>
  </configuration>
</plugin>

回答by Loki

try that:

试试看:

<version>1.2</version>

http://repo2.maven.org/maven2/org/codehaus/mojo/findbugs-maven-plugin/

http://repo2.maven.org/maven2/org/codehaus/mojo/findbugs-maven-plugin/

Seems like they did a simple copy/paste error.

似乎他们做了一个简单的复制/粘贴错误。

回答by Rob Di Marco

The report will be in target/site. Look at the file index.html in a browser, than look for project reports, then findbugs report.

报告将在目标/站点中。在浏览器中查看文件 index.html,然后查找项目报告,然后查找错误报告。

回答by 01es

As part of your parent project structure place site.xml into parent-project/src/site:

作为父项目结构的一部分,将 site.xml 放入 parent-project/src/site:

 |--- src 
      |---site
            |---site.xml 

An example site.xml from "Better Builds with Maven" (a free book available online) should get you started.

来自“Better Builds with Maven”(在线免费书籍)的示例 site.xml 应该可以帮助您入门。

Once site.xml is created, execute mvn sitefrom the parent project directory. It will pick up your reporting settings including the firebug report. Once the site is built, each child project will have directory /target/site, which contains index.html with a link to project reports. The project reports should contain firebug reports.

创建 site.xml 后,mvn site从父项目目录执行。它将获取您的报告设置,包括萤火虫报告。站点建成后,每个子项目都会有目录 /target/site,其中包含 index.html 和项目报告的链接。项目报告应包含萤火虫报告。