java注解@Interface与Annotation 财富值96
生活随笔
收集整理的這篇文章主要介紹了
java注解@Interface与Annotation 财富值96
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
我有一個(gè)對(duì)象被@Configuration注解,那我怎么知道它還是被Component注解的?
沒聽懂
@interface 是聲明注解的關(guān)鍵字(與class/interface一樣)
Annotation 也可以獲取自身的注解。
注:Meta-Annotations并不是Annotation的原生功能,只是在spring中實(shí)現(xiàn)了這種機(jī)制。如果單純的使用原生的Annotation則需要自己解析Meta-Annotations實(shí)現(xiàn)相應(yīng)的功能才行。
obj.getClass().getAnnotation(Configuration.class).getClass() == Configu??ration.class 引用不同結(jié)果為false是正常情況。可以使用這種判斷obj.getClass().getAnnotation(Configuration.class).getClass().getName().equals(Configu??ration.class.getName())
沒聽懂
@interface 是聲明注解的關(guān)鍵字(與class/interface一樣)
Annotation 也可以獲取自身的注解。
注:Meta-Annotations并不是Annotation的原生功能,只是在spring中實(shí)現(xiàn)了這種機(jī)制。如果單純的使用原生的Annotation則需要自己解析Meta-Annotations實(shí)現(xiàn)相應(yīng)的功能才行。
obj.getClass().getAnnotation(Configuration.class).getClass() == Configu??ration.class 引用不同結(jié)果為false是正常情況。可以使用這種判斷obj.getClass().getAnnotation(Configuration.class).getClass().getName().equals(Configu??ration.class.getName())
總結(jié)
以上是生活随笔為你收集整理的java注解@Interface与Annotation 财富值96的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: uva 10110——Light, mo
- 下一篇: 长期使用化妆品会导致不孕不育吗