What is the default annotation processors discovery process?

江枫思渺然 提交于 2019-11-26 13:52:14

问题


The documentation of Maven Compiler plugin mentions the following:

annotationProcessors:

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?

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?


回答1:


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.



来源:https://stackoverflow.com/questions/11685498/what-is-the-default-annotation-processors-discovery-process

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