gpt4 book ai didi

java - java中的@Documented注解

转载 作者:IT老高 更新时间:2023-10-28 20:24:22 24 4
gpt4 key购买 nike

@Documented注解在java中的作用是什么?

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

最佳答案

@Documented 是一个元注释。您在定义注解时应用 @Documented,以确保使用您的注解的类在其生成的 JavaDoc 中显示这一点。我没有看到它有太多用处,但是 there is an example here .较早的问题表明它 doesn't work automatically in Eclipse ,但我已经在 Eclipse 3.6 中进行了测试,无论我是否将 @Documented 注释附加到它们,我的注释都会出现在 JavaDoc 弹出窗口中。

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

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

关于java - java中的@Documented注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5592703/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com