如何在源代码中以编程方式定义 myAnnotationProcessor?
我刚刚接触注释。 我创建了一个示例annotationProcessor来处理我的注释,并且当前使用命令行脚本“-processor defaultproject.annotations.DefaultProcessor”来使用它。
有什么方法可以从代码内部设置这个处理器吗?
多谢 莫因
I'm just new to annotations.
I've created a sample annotationProcessor to handle my annotations and currently using command line script "-processor defaultproject.annotations.DefaultProcessor " to use it.
is there any way to set this processor from inside the code?
thanks a lot
Moein
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理器接口说的是发现过程:
在类路径中定义处理器的最佳选择是提供包含文本
defaultproject.annotations.DefaultProcessor
的META-INF/services/javax.annotation.processing.Processor
文件。(假设您的工具链支持此机制。这最终取决于编译器/工具/IDE。)
The Processor interface says this about the discovery process:
Your best bet for defining the processor in your classpath is to provide a
META-INF/services/javax.annotation.processing.Processor
file containing the textdefaultproject.annotations.DefaultProcessor
.(Assuming your tool chain supports this mechanism. This is ultimately compiler/tool/IDE dependent.)