2011-04-08 142 views

回答

37

@Documented是一个元注释。在定义注释时应用@Documented,以确保使用注释的类在其生成的JavaDoc中显示。我没有看到太多的用处,但是there is an example here。先前的问题表明它是doesn't work automatically in Eclipse,但我已在Eclipse 3.6中进行了测试,并且我的注释出现在JavaDoc弹出窗口中,而不管我是否将@Documented注释附加到它们。

下面是从弹簧,这确保事务性方法标记为这样在JavaDoc一个例子:

​​3210
2

我发现了一个有用的页面在Java Tutorials其给出的例子和更多的解释了许多标准的注释,其中包括使用@Documented。具体来说,请看底部的备注块的前导示例(section Documentation)。

+0

链接现在已经死了 – 2013-05-15 14:45:04

+0

链接是固定的 – Sithsu 2013-07-20 16:06:55

23

如果我们的一些注解,说@InWork@Documented,则有@InWork每一个类,javadoc所产生的含有@InWork文本,对注释的参考文本。

译注:

@Documented 
@Inherited // for descenders of the annotation to have the @Documented feature automatically 
@Retention(RetentionPolicy.RUNTIME) // must be there 
public @interface InWork { 
    String value(); 
} 

注释目标:

/** 
* Annotated class. 
*/ 
@InWork(value = "") 
public class MainApp {...} 

的Javadoc文本:

enter image description here

所以,你必须决定,如果注释应显示javadoc文本,如果是,则将@Documented设置为i吨。

以上信息摘自Oracle documentation


请,通知,在Eclipse中,你会在Javadoc生成文本中看到所有的注解,是他们@Documented,还是不行。

4.3版本仍然正确。