What is the default annotation processors discovery process?(什么是默认注释处理器发现过程?)
问题描述
Maven 编译器插件的文档中提到了以下内容:
注解处理器:
要运行的注释处理器的名称.仅适用于 JDK 1.6+ 如果不是设置,则应用默认注释处理器发现过程.
Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies.
这里的默认注释处理器发现过程是什么?除了这个配置标签,还有其他方法可以设置注解处理器吗?
What is the default annotation processors discovery process here? Is there any other way to set up annotation processors than this configuration tag?
我发现入门注释处理工具 (apt) 文档提到了一个默认发现过程,但它适用于 工厂类 而不是处理器,不幸的是它使用 tools.jar来自 JDK 的
和 com.sun
包.这是默认的注释处理器发现过程吗?
I've found that the Getting Started with the Annotation Processing Tool (apt) documentation mentions a default discovery procedure, but it works with factory classes not processors and unfortunately it uses the tools.jar
and com.sun
packages from the JDK. Is this the default annotation processors discovery process?
推荐答案
让编译器可以使用注解处理器的默认方法是在 META-INF/services/javax.annotation 的文件中注册它.processing.Processor
.该文件可以包含许多处理器:每个处理器都在其自己的行上是完全限定的类名,最后有一个换行符.如果未指定任何处理器,编译器将默认使用以这种方式找到的处理器.
The default way to make an annotation processor available to the compiler is to register it in a file in META-INF/services/javax.annotation.processing.Processor
. The file can contain a number of processors: each the fully-qualified class name on its own line, with a newline at the end. The compiler will default to using processors found in this way if none are specified.
这篇关于什么是默认注释处理器发现过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么是默认注释处理器发现过程?


基础教程推荐
- Java:带有char数组的println给出乱码 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01