如何在 Eclipse 中配置 Java 注释处理器? [英] How to configure Java Annotation Processor(s) in Eclipse?

查看:51
本文介绍了如何在 Eclipse 中配置 Java 注释处理器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过使用 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 文件包含到 项目属性 ->注释处理 ->工厂路径.我还在 Project Properties -> 中提供了 -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.

  1. 右键单击项目并选择属性.
  2. 打开 Java 编译器 -> 注释处理.选中启用注释处理".
  3. 打开Java编译器->注解处理->工厂路径.选中启用项目特定设置".将您的 JAR 文件添加到列表中.
  4. 清理并构建项目.

它终于奏效了.

这篇关于如何在 Eclipse 中配置 Java 注释处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆