逐步抑制findbugs警告

时间:2014-08-27 11:08:02

标签: java maven maven-2 findbugs suppress-warnings

我想通过在方法开头之前输入这一行来抑制单个Findbug警告("将非常量字符串传递给SQL语句的执行方法"):

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = {"SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE", "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" }, justification = "just a test")

但Eclipse一直说edu无法解析为类型,并且注释类型SuppressWarnings的属性对齐未定义。 在findbugs文档中,我读到我必须在Java Build Path中添加annotations.jar和jsr305.jar(在Project Properties中)。但是在findbugs文件夹中我找不到任何.jar文件。只有findbugs.xml,findbugs-excludes.xml等等。

我该怎么做才能让它运转起来?我使用Findbugs maven插件2.5.2。

非常感谢!

1 个答案:

答案 0 :(得分:3)

下载并添加到您的类路径中:

http://www.java2s.com/Code/Jar/a/Downloadannotations201jar.htm

或使用官方maven存储库:

<dependency>
    <groupId>findbugs</groupId>
    <artifactId>findbugs</artifactId>
    <version>1.0.0</version>
</dependency>

链接:http://mvnrepository.com/artifact/findbugs/findbugs/1.0.0

或者使用这个maven片段:

<dependency>
    <groupId>com.kenai.nbpwr</groupId>
    <artifactId>edu-umd-cs-findbugs-annotations</artifactId>
    <version>unknown</version>
</dependency>
相关问题