[英]Suppressing findbugs warning Step by Step
我想通过在方法开头之前输入以下行来抑制单个Findbug警告(“将非常量字符串传递给SQL语句上的execute方法”):
@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。
非常感谢你!
下载并添加到您的类路径:
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.