Eclipse AutoValue class fails to build

走远了吗. 提交于 2019-12-05 12:11:24

It appears that the dependency com.google.code.findbugs:jsr305 is missing when Eclipse runs the annotation processor. Try adding it by opening the project properties, browsing to Java Compiler -> Annotation Processing -> Factory Path, clicking on "Add External JARs" and then selecting the jsr305 JAR. If you have built the project with maven from the command line, you should be able to select the JAR from your .m2 directory.

Here's what the proprties look like in my project (the first entry is automatically added by Eclipse and doesn't seem to be relevant):

In the pom.xml in version 1.0-rc1 of AutoValue, there is a comment "Must have this where procesor runs" at the jsr305 dependency. The dependency was removed after the release of 1.0-rc1, so adding it to the annotation processor factory path will probably not be necessary with version 1.0.

See also this blog post for an introduction to using AutoValue with Eclipse.

You might want to install the m2e-apt plugin, which handles automatic annotation processing based on the pom.xml dependencies:

https://marketplace.eclipse.org/content/m2e-apt

Make sure to enable it in you project preferences or globally in section:

Maven -> "Annotation processing" -> select "Automatically configure JDT APT..."

Detailed info here and here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!