maven忽略findbugs suppressFBWarnings注释

maven忽略findbugs suppressFBWarnings注释,maven,maven-plugin,findbugs,Maven,Maven Plugin,Findbugs,我有两个项目,我正在使用maven中的FindBugs插件来识别bug。我还使用了@SuppressFBWarnings注释来忽略特定的bug 在第一个项目中,我将依赖项添加到pom.xml中,findbugs报告和注释都运行良好。对于第二个项目,会生成报告,但它仍然会识别我使用注释抑制的bug 我运行mvn clean install site在我的机器上的build文件夹中生成报告 我提到的两个项目中的每一个都有子项目,子目录中有自己的pom.xml文件,因此在父目录中,我也有一个pom.x

我有两个项目,我正在使用
maven
中的
FindBugs
插件来识别bug。我还使用了
@SuppressFBWarnings
注释来忽略特定的bug

在第一个项目中,我将依赖项添加到pom.xml中,findbugs报告和注释都运行良好。对于第二个项目,会生成报告,但它仍然会识别我使用注释抑制的bug

我运行
mvn clean install site
在我的机器上的build文件夹中生成报告

我提到的两个项目中的每一个都有子项目,子目录中有自己的pom.xml文件,因此在父目录中,我也有一个pom.xml文件。此目录布局在两个主要项目中镜像相同

以下是我在
标记下添加到父POM的XML:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <xmlOutput>true</xmlOutput>
        <findbugsXmlOutput>true</findbugsXmlOutput>
        <fork>true</fork>
        <threshold>Low</threshold>
        <effort>Min</effort>
    </configuration>
</plugin>
此外,这也反映在其他工作项目中。我直接复制粘贴

一个项目工作完美,我可以成功地抑制误报。另一个项目完全忽略了
@SuppressFBWarnings
anotion,我似乎无法修复它

这里有我遗漏的东西吗

我认为如果找不到注释,它不会给出错误,而是会忽略它?如果找不到,我怎么知道呢

希望这是一个简单的解决方案


谢谢。

尝试将注释artifcat添加到插件依赖项:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <xmlOutput>true</xmlOutput>
        <findbugsXmlOutput>true</findbugsXmlOutput>
        <fork>true</fork>
        <threshold>Low</threshold>
        <effort>Min</effort>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
            <version>2.0.1</version>
        </dependency>
    </dependencies>
</plugin>

org.codehaus.mojo
findbugs maven插件
2.3.2
真的
真的
真的
低
分钟
com.google.code.findbugs
注释
2.0.1

@SuppressFBWarnings在版本3中随注释一起引入。这就是为什么它应该是这样的:

<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>annotations</artifactId>
    <version>3.0.1</version>
</dependency>

com.google.code.findbugs
注释
3.0.1

确保添加的依赖项位于依赖项标记之间。 像这样:

<dependencies>
  <dependency>
     <groupId>something</groupId>
     <artifactId>something</artifactId>
      <version>something</version>
  </dependency>
<dependencies>

某物
某物
某物

Hi Omar,谢谢你的回复,但是当我尝试这样做时,我得到了以下错误:
cvc复杂类型。2.4.a:发现以元素“dependencies”开头的无效内容。“{”之一http://maven.apache.org/POM/4.0.0“:继承,”http://maven.apache.org/POM/4.0.0“:reportSets}”应为。
文件中可能有不可见字符。试着用你的文本编辑器显示隐藏的字符(notpad++),我忘了跟进。基本上,我是通过使用普通的findbugs
SuppressWarnings
而不是
SuppressFBWarnings
来实现的。我认为标准的
SuppressWarnings
注释和findbugs注释都有问题,可能与JAR问题结合在一起。eoinzy:意味着你根本没有让它与SuppressFBWarnings一起工作?当我按这里描述的那样尝试时,它对我不起作用。
<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>annotations</artifactId>
    <version>3.0.1</version>
</dependency>
<dependencies>
  <dependency>
     <groupId>something</groupId>
     <artifactId>something</artifactId>
      <version>something</version>
  </dependency>
<dependencies>