什么是默认的注解处理器发现过程? [英] What is the default annotation processors discovery process?

查看:125
本文介绍了什么是默认的注解处理器发现过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的<一个href=\"http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessors\">documentation Maven的编译器插件提到了以下:

annotationProcessors:

注解处理器的名称来运行。只适用于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 /服务/使用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.

这篇关于什么是默认的注解处理器发现过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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