问题描述
我看到文档,但无法获取到 c> @Documented 很多从它。有人可以借助一个清晰的例子来指出
@Documented 是元注释。在定义注释时,您应用 @Documented ,以确保使用注释的类在其生成的JavaDoc中显示。我没有看到太多的用处,但是。一个较早的问题表明,,但是我已经在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!