Search code examples
javamavenmaven-2findbugssuppress-warnings

Suppressing findbugs warning Step by Step


I want to suppress a single Findbug warning ("passes a nonconstant String to an execute method on an SQL statement") by entering this line before the beginning of the method:

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

But Eclipse keeps saying that edu cannot be resolved to a type and The attribute justification is undefined for the annotation type SuppressWarnings. In the findbugs documentation i read that I have to add the annotations.jar and jsr305.jar in Java Build Path (in Project Propertes). But in the findbugs folder I cant find any .jar file. Only findbugs.xml, findbugs-excludes.xml and so on.

What can I do to get this running? I Use Findbugs maven plugin 2.5.2.

Thank you very much!


Solution

  • Download it and add to your classpath:

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

    Or use the official maven repository:

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

    Link: http://mvnrepository.com/artifact/findbugs/findbugs/1.0.0

    Or use this maven snippet:

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