@Documented注解作用
验证步骤
1. 编写 注解 + 类
// 第一个文件
package com.example.zhaohuiweb;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* TODO 业务描述
*
* @author xiezhaohui
* @date 2022/12/17 11:04
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
// 代表文档上面注解是否生效 先注释掉后续开启
// @Documented
public @interface Hello {
}
// 第二个文件
package com.example.zhaohuiweb;
/**
* TODO 业务描述
*
* @author xiezhaohui
* @date 2022/12/17 11:01
*/
@Hello
public interface IService {
}
2. 执行Javadoc命令生成文档
main\java> javadoc -encoding UTF-8 com.example.zhaohuiweb
3. 查看IService类文档信息
4. 取消// @Documented 注解 生成文档并查看
总结
@Documented注解会影响javadoc生成的类上面是否保留注解