java中的@Documented注解 [英] @Documented annotation in java

查看:28
本文介绍了java中的@Documented注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java中@Documented注解的目的是什么?

What's the purpose of @Documented annotation in java?

我看到了文档,但无法从中获得太多信息.有人可以在一个清晰的例子的帮助下指出

I saw the documentation, but could not get much from it. Can someone point out with the help of an clear example

推荐答案

@Documented 是一个元注释.您在定义注释时应用 @Documented,以确保使用您的注释的类在其生成的 JavaDoc 中显示这一点.我没有看到太多使用它,但是 这里有一个例子.较早的问题表明它在 Eclipse 中无法自动工作,但我已经在 Eclipse 3.6 中进行了测试,无论我是否将 @Documented 注释附加到它们,我的注释都会出现在 JavaDoc 弹出窗口中.

@Documented is a meta-annotation. You apply @Documented when defining an annotation, to ensure that classes using your annotation show this in their generated JavaDoc. I've not seen much use of it, but there is an example here. An earlier question suggests that it doesn't work automatically in Eclipse, but I've tested in Eclipse 3.6, and my annotations appear in the JavaDoc popups whether or not I attach the @Documented annotation to them.

下面是 Spring 的一个例子,它确保事务方法在 JavaDoc 中被标记为这样:

Here's an example from Spring, which ensures that transactional methods are marked as such in the JavaDoc:

@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Transactional {

这篇关于java中的@Documented注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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