如何在Eclipse中配置Java注释处理器? [英] How to configure Java Annotation Processor(s) in Eclipse?
问题描述
我已经使用Java 8通过命令提示符编译成功运行CLASS级别保留注释的注释处理器。
I have successfully run annotation processor for CLASS level retention annotations via command prompt compiling using Java 8.
然而,当我尝试在eclipse中配置注释处理器时试图用 - proc:only
选项运行它,它没有生效。
However, when I tried to configure the annotation processor in eclipse and tried to run it with "-proc:only"
option, it didn't get effective.
我有将包含自定义注释处理器类文件的Jar文件包含在项目属性 - >中。注释处理 - >工厂路径
。我还在项目属性 - >中提供了
,当执行包含我的注释的类时,仍未调用注释处理器。 -proc:only
选项。注释处理 - >处理器选项
I have included the Jar file containing the custom annotation processor class file into the Project Properties -> Annotation Processing -> Factory Path
. I have also provided the -proc:only
option in Project Properties -> Annotation Processing -> Processor Options
, still the annotation processor isn't getting called when a class containing my annotation is executed.
请帮我识别所需的设置或通过eclipse运行注释处理器的错误或额外步骤。
Please help me identifying the required setting or mistake or additional step for running the annotation processor via eclipse.
推荐答案
我终于能够通过添加启用我自己的注释处理器我的jar文件。
I was finally able to enable my own annotation processor by adding my jar file.
- 右键单击项目并选择Properties。
- 打开Java编译器 - >注释处理。选中启用注释处理。
- 打开Java编译器 - >注释处理 - >工厂路径。选中启用项目特定设置。将您的JAR文件添加到列表中。
- 清理并构建项目。
- Right click on the project and select Properties.
- Open Java Compiler -> Annotation Processing. Check "Enable annotation processing".
- Open Java Compiler -> Annotation Processing -> Factory Path. Check "Enable project specific settings". Add your JAR file to the list.
- Clean and build the project.
它终于工作了。
这篇关于如何在Eclipse中配置Java注释处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!