如何创建自定义 Annotation 并使用 APT 处理它? [英] How to create a custom Annotation and processing it using APT?

查看:26
本文介绍了如何创建自定义 Annotation 并使用 APT 处理它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Java 注释的新手.我知道如何创建自定义注释,但我不知道如何处理该注释以生成动态代码,就像 ejb 3.0 和 hibernate 一样.
我看了一些基于APT的文章,但没有人详细说明如何处理Annotation.
是否有包含用于处理自定义注解的示例代码的教程?

I'm new to Java Annotation. I know how to create custom annotation but I don't know how to process that Annotation to generate the dynamic code just like ejb 3.0 and hibernate does.
I read some articles based on APT but no one gives the details about how to process the Annotation.
Are there any tutorials with sample code for processing custom Annotations?

谢谢

推荐答案

开始于... apt 入门指南.更进一步,您可以查看 JPA 2.0 提供程序用于生成静态元模型类的注释处理器的来源,例如 Hibernate 的类:ohjJPAMetaModelEntityProcessor.java

Start with... the apt getting started guide. To go further, you could maybe have a look at the sources of annotation processor used by JPA 2.0 providers to generate the static meta model classes, for example Hibernate's one: o.h.j.JPAMetaModelEntityProcessor.java

这篇关于如何创建自定义 Annotation 并使用 APT 处理它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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