当前位置:网站首页>@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 )
边栏推荐
- [JVM optimization ultra detailed] common JVM tuning scenarios
- ArcGIS JS customizes the accessor and uses the watchutils related method to view the attribute
- 基于单例模式的yaml参数配置
- These mobile security browsers are more than a little easy to use
- EMC之 “不整改好别回来了”
- How to understand the adjective prefix of socket: "connection oriented" and "connectionless"
- "Wei Lai Cup" 2022 Niuke summer multi school training camp 2 supplementary question record (dghjkl)
- The first common node of two linked lists -- two questions per day
- 【着色器实现Negative反色效果_Shader效果第十一篇】
- Modify the conf file through sed
猜你喜欢

DNA修饰金属锇Os纳米颗粒OsNPS-DNA|DNA修饰金属铱纳米颗粒IrNPS-DNA

Protobuf basic grammar summary

细说共模干扰和差模干扰

【干货】32个EMC标准电路分享!

EMC's "don't come back until you rectify"

XMPP Service Research (II) prosody create account

Don't be afraid of ESD static electricity. This article tells you some solutions
![[dry goods] 32 EMC standard circuits are shared!](/img/51/cff9dd7e033ca2df917307e9fe38ff.jpg)
[dry goods] 32 EMC standard circuits are shared!

Daily question - split equal sum subset

The cornerstone of EMC - complete knowledge of electromagnetic compatibility filtering!
随机推荐
RFID辐射测试小结
Summary of project experience
Rk3568 development board installation system startup
2022/7/27 examination summary
It has been rectified seven times and took half a month. Painful EMC summary
DNA脱氧核糖核酸修饰金属铂纳米颗粒PtNPS-DNA|科研试剂
Eventbus of guava
Forward propagation of deep learning neural networks (1)
The cornerstone of EMC - complete knowledge of electromagnetic compatibility filtering!
【17】建立数据通路(上):指令+运算=CPU
Google and Stanford jointly issued a document: why do we have to use large models?
Huawei Senior Engineer -- BGP routing filtering and community attributes
Swm32 series tutorial 5-adc application
@Documented 的作用
EMC design strategy - clock
Tensorflow uses deep learning (II)
EMC设计攻略 —时钟
ESD静电不用怕,本文告诉你一些解决方法
How do we run batch mode in MySQL?
Daily question - split equal sum subset