当前位置:网站首页>@The role of documented
@The role of documented
2022-07-28 07:55:00 【It's just a small front end】
1. @Documented The meaning of
- @Document yes java Document generation , Whether to display the switch of annotation .
2. What's the difference between adding and not adding ?
Test notes
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RestMapping {
String[] value() default {};String[] path() default {};
}Test class TerminalController
@RestMapping(“/terminal”)
public class TerminalController {Use command
// Generate java doc The order of :
javadoc -d doc TerminalController.java`
// -d The destination directory of the output file
a. No effect

b. Plus the effect of

You can see in the public class TerminalController There is a note we wrote on it . This is it. @Documented Usefulness .
3. Digression : Annotation merge
java Annotations are just a kind of annotation that will not be ignored by the compiler notes . It has no effect on code logic ( Can be used to determine whether there is , Can read content information ), And the use effect is completely determined by the use of tools .
Annotations are used by many specifications , As a sign or convention , Such as jsr303 Parameter checking .
a. Annotation merge
stay springboot Annotations in play a great role , And these functions only in springboot Useful in , like @AliasFor.
Annotations themselves cannot be inherited by annotations , and springboot You can see a lot of merge annotations in the @RestController = @Controller + @ResponseBody. This is it. @AliasFor Credit . It should be noted that , Leave Spring Can't use .
spring The annotations of are read by the following class , therefore spring Annotations of can be merged ( Yes and only spring annotation :Spring Annotations)
public interface MergedAnnotations
b. @AliasFor
@AliasFor It has four functions :
Explicit aliases in comments :
stay @ContextConfiguration in , value and locations Is an explicit alias for each other .public @interface ContextConfiguration {
@AliasFor(“locations”)
String[] value() default {};@AliasFor(“value”)
String[] locations() default {};// …
}Explicit aliases of attributes in meta annotations :
stay @XmlTestConfig in , xmlFiles yes @ContextConfiguration in locations Explicit alias for . let me put it another way , xmlFiles covers @ContextConfiguration Medium locations attribute .@ContextConfiguration
public @interface XmlTestConfig {@AliasFor(annotation = ContextConfiguration.class, attribute = "locations") String[] xmlFiles();}
Implicit aliases in comments :
stay @MyTestConfig in , value 、 groovyScripts and xmlFiles All are @ContextConfiguration in locations The explicit meta annotation property of the property overrides . therefore , These three attributes are also implicit aliases to each other .@ContextConfiguration
public @interface MyTestConfig {
@AliasFor(annotation = ContextConfiguration.class, attribute = “locations”)
String[] value() default {};@AliasFor(annotation = ContextConfiguration.class, attribute = “locations”)
String[] groovyScripts() default {};@AliasFor(annotation = ContextConfiguration.class, attribute = “locations”)
String[] xmlFiles() default {};
}Pass through implicit aliases in comments :
stay @GroovyOrXmlTestConfig in , groovy It's right @MyTestConfig in groovyScripts Explicit overrides of attributes ; and xml It's right @ContextConfiguration Medium locations Explicit overrides of attributes . Besides , groovy and xml Are each other's Transitive implicit aliases , Because they all effectively cover @ContextConfiguration Medium locations attribute .@MyTestConfig
public @interface GroovyOrXmlTestConfig {
@AliasFor(annotation = MyTestConfig.class, attribute = “groovyScripts”)
String[] groovy() default {};@AliasFor(annotation = ContextConfiguration.class, attribute = “locations”)
String[] xml() default {};
}
( End )
边栏推荐
- Introduction to magnetic ring selection and EMC rectification skills
- The net loss of users occurred again, and China Mobile, which lost face, launched ultra-low price packages to win users
- 基于单例模式的yaml参数配置
- JUC atomic class: CAS, unsafe, CAS shortcomings, how to solve ABA problems in detail
- 登录模式:单一服务器模式、单点登录、token模式
- Delete the nodes in the linked list - daily question
- Digital management insight into retail and e-commerce operations -- Introduction to digital management
- ASP.NET Core 技术内幕与项目实战读后感
- [JVM optimization] online JVM tuning practice
- Opencv's practical learning of credit card recognition (4)
猜你喜欢

Information system project manager must recite the core examination site (41) risk management plan

Elaborate on common mode interference and differential mode interference

ESD防护为何对集成电路如此重要?又该如何防护?

The underlying principles of RDB persistence and AOF persistence of redis

Protobuf basic grammar summary
![[solution] visual full link log tracking - log tracking system](/img/0c/f93c7d31e01257c5dee7d292ac7d84.jpg)
[solution] visual full link log tracking - log tracking system

Near infrared two region agzs quantum dots wrapped deoxyribonucleic acid dna|dna agzsqds (Qiyue)

The net loss of users occurred again, and China Mobile, which lost face, launched ultra-low price packages to win users

Forward propagation of deep learning neural networks (1)

细说共模干扰和差模干扰
随机推荐
【13】加法器:如何像搭乐高一样搭电路(上)?
Chapter 01 introduction of [notes of Huashu]
awk从入门到入土(16)awk变量类型探讨--关于数字和string两种类型
Modify the conf file through sed
How to understand the adjective prefix of socket: "connection oriented" and "connectionless"
非关系型数据库之Redis【Jedis客户端+Jedis连接集群】
After being accidentally dragged into QQ fraud group
win系统添加打印机
Discrimination coverage index / index coverage / Samsung index
Will ordinary browsers disclose information? How to protect privacy by using a secure browser?
Elaborate on common mode interference and differential mode interference
The cornerstone of EMC - complete knowledge of electromagnetic compatibility filtering!
EMC整改方法集合
MySQL: what is the difference between like and regexp operations?
基于单例模式的yaml参数配置
EMC之 “不整改好别回来了”
DNA修饰贵金属纳米颗粒|DNA脱氧核糖核酸修饰金属钯Pd纳米颗粒PdNPS-DNA
任务管理器中,显示的CPU速度大于它的最大速度【主频】
mysql,可以使用多少列创建索引?
DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂