@Documented注释在java [英] @Documented annotation in java

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

问题描述



我看到文档,但无法获取到 c> @Documented 很多从它。有人可以借助一个清晰的例子来指出

解决方案

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



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

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


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 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.

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 {

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

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