当前位置:网站首页>@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 )
边栏推荐
- 谈谈DOM0,DOM1,DOM2,DOM3
- Adjust the array order so that odd numbers precede even numbers - two questions per day
- 整改了七次,花了半个月时间,惨痛的EMC总结
- 【着色器实现Negative反色效果_Shader效果第十一篇】
- How to analyze the taxi business problem of didi SQL interview question
- EMC design strategy - clock
- 4.1.4 why set the member variable to private
- 数据化管理洞悉零售及电子商务运营——数据化管理介绍
- Flowable workflow all business concepts
- Delete the nodes in the linked list - daily question
猜你喜欢

Matplotlib绘图笔记基础直线、折线、曲线

数据化管理洞悉零售及电子商务运营——数据化管理介绍

Digital management insight into retail and e-commerce operations -- Introduction to digital management

Forward propagation of deep learning neural networks (1)

protobuf 基本语法总结

SWM32系列教程5-ADC应用

Synthesis of dna-ag2sqds DNA modified silver sulfide Ag2S quantum dots

【着色器实现Negative反色效果_Shader效果第十一篇】

Elaborate on common mode interference and differential mode interference

解析树形结构 js
随机推荐
Opencv's practical learning of credit card recognition (4)
MySQL basic knowledge learning (II)
Synthesis of dna-ag2sqds DNA modified silver sulfide Ag2S quantum dots
滴滴SQL面试题之打车业务问题如何分析
Merge two sorted linked lists - two questions per day
磁环选型攻略及EMC整改技巧
JUC atomic class: CAS, unsafe, CAS shortcomings, how to solve ABA problems in detail
辨析覆盖索引/索引覆盖/三星索引
Swm32 series tutorial 5-adc application
PCB design skills of EMC
【着色器实现Negative反色效果_Shader效果第十一篇】
Rk3568 development board installation system startup
Freezing and thawing of pytoch
C language explanation series - array explanation, one-dimensional array, two-dimensional array
干货|分享一个EMC实际案例及整改过程
@Documented 的作用
And is two numbers of S - two questions per day
“蔚来杯“2022牛客暑期多校训练营2补题记录(DGHJKL)
DNA modified rhodium RH nanoparticles rhnps DNA (DNA modified noble metal nanoparticles)
The cornerstone of EMC - complete knowledge of electromagnetic compatibility filtering!