问题
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