Can't find @Nullable inside javax.annotation.*

2019-01-30 20:41发布

I want use @Nullable annotation to eliminate NullPointerExceptions. I found some tutorials on the net, I noticed that this annotation comes from the package javax.annotation.Nullable; but when I import it a compilation error is generated: cannot find symbol

8条回答
贪生不怕死
2楼-- · 2019-01-30 21:19

In case someone has this while trying to compile an Android project, there is an alternative Nullable implementation in android.support.annotation.Nullable. So take care which package you've referenced in your imports.

查看更多
混吃等死
3楼-- · 2019-01-30 21:23

The artifact has been moved from net.sourceforge.findbugs to

<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>jsr305</artifactId>
    <version>3.0.0</version>
</dependency>
查看更多
登录 后发表回答