The type org.eclipse.jdt.annotation.NonNull cannot be resolved. It is indirectly referenced from required .class files

前端 未结 3 444
广开言路
广开言路 2021-02-01 17:24

When I use the Java 8 method reference double colon operator (::) with new operator (e.g. MyType::new), I get this error in Eclipse of Spring Tool suit

3条回答
  •  [愿得一人]
    2021-02-01 17:45

    Eclipse has a feature called annotation-based null analysis, which provides compile-time checks using annotations (e.g. @NonNull or @Nullable). You get this error when annotations are missing in the classpath.

    If you don't plan to use the annotation-based null analysis feature, you can just disable it in Eclipse.

    Open the global or project settings and go to Java > Compiler > Warnings. In the Null analysis category, uncheck Enable annotation-based null analysis. Then rebuild the workspace and those errors won't show again.

提交回复
热议问题