Where is javax.annotation

后端 未结 4 1433
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 07:24

Ok, so this is probably a NooB question (I\'m more of a C++ guy), but I\'m lost in the java woods and its frameworks forests...

I\'m trying to look into eclipse RCP

相关标签:
4条回答
  • 2021-01-17 08:03

    Your comment indicates this is for Guava, so you want the JSR305 library, which extends the javax package.

    2020 Update: Note that this library breaks the Oracle licensing agreement and Guava has since moved to checkerframework's Nullable annotation.

    0 讨论(0)
  • 2021-01-17 08:12

    The dependency including version:

    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.3.2</version>
    </dependency>
    

    See: http://mvnrepository.com/artifact/javax.annotation/javax.annotation-api

    Or for the newerjakarta.annotation:

    <dependency>
       <groupId>jakarta.annotation</groupId>
       <artifactId>jakarta.annotation-api</artifactId>
       <version>1.3.5</version>
    </dependency>
    

    See: https://mvnrepository.com/artifact/jakarta.annotation/jakarta.annotation-api

    The Java Common Annotations Module java.xml.ws.annotation was deprecated in Java version 9 and was removed in java version 11. If this leads to a problem you could try to add javax.annotation.

    The Javadocs for Java 8 can be found here: http://docs.oracle.com/javase/8/docs/api/javax/annotation/package-summary.html

    0 讨论(0)
  • 2021-01-17 08:23

    In Java version >= 6, you should not need to add them explicitly.
    They are part of the JDK. Just try to skip adding them, maybe
    the list of instructions is outdated.

    Before Java 6, you would have needed to add this jar, I think: jsr250-api-1.0.jar.

    http://central.maven.org/maven2/javax/annotation/jsr250-api/1.0/

    http://download.java.net/maven/2/javax/annotation/jsr250-api/1.0/

    0 讨论(0)
  • 2021-01-17 08:27

    Not sure if this is still relevant, but for Java 8, I had to add the two following Maven dependencies in order to get javax.annotation.concurrent.ThreadSafe to work:

        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
    
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.0</version>
        </dependency> 
    
    0 讨论(0)
提交回复
热议问题