Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
@java中的文档化注释_Java_Eclipse_Annotations - Fatal编程技术网

@java中的文档化注释

@java中的文档化注释,java,eclipse,annotations,Java,Eclipse,Annotations,java中@文档化的注释的目的是什么 我看了文档,但没能从中得到什么。有人能用一个清晰的例子指出吗@Documented是一个元注释。定义注释时应用@Documented,以确保使用注释的类在其生成的JavaDoc中显示这一点。我没看到它有多大用处,但是。前面的一个问题表明是这样的,但我已经在Eclipse3.6中进行了测试,我的注释会出现在JavaDoc弹出窗口中,无论我是否将@Documented注释附加到它们上 下面是Spring的一个示例,它确保事务方法在JavaDoc中被标记为事务方法

java中
@文档化的
注释的目的是什么


我看了文档,但没能从中得到什么。有人能用一个清晰的例子指出吗

@Documented
是一个元注释。定义注释时应用
@Documented
,以确保使用注释的类在其生成的JavaDoc中显示这一点。我没看到它有多大用处,但是。前面的一个问题表明是这样的,但我已经在Eclipse3.6中进行了测试,我的注释会出现在JavaDoc弹出窗口中,无论我是否将
@Documented
注释附加到它们上

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

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

我在中找到了一个有用的页面,其中给出了一些标准注释的示例和更多解释,包括一个使用
@Documented
。具体来说,请查看序言示例()底部的注释块。

如果我们的一些注释(例如,
@InWork
)是
@文档化的
,那么对于具有该
@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文本:

因此,您必须决定注释是否应显示在javadoc文本中,如果是,则将
@Documented
设置为注释

以上信息摘自


请注意,在Eclipse中,您将在javadoc生成的文本中看到所有注释,它们是
@Documented
,还是没有

它对于4.3版本仍然是正确的