Spring框架标注问题 [英] Spring framework annotation question
本文介绍了Spring框架标注问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在支持XML和注释情况下,当春天的框架做了注释扫描以及如何处理呢?
有人能给予详细的情况?
有关XmlWebApplicationContext,用它loadBeanDefinations()通过XML文件。但是,当它做注释扫描和使用的类来处理它?</ P>
可以解释为细节?
感谢。
富兰克林
解决方案
在基于XML的应用程序上下文,注释只有当你明确地配置注册:
&LT;! - 寄存器的默认注释(例如@Required) - GT;
&LT;背景:注解配置/&GT;&LT;! - 扫描选定的套装部件 - &GT;
&LT;背景:组件扫描基包=org.example/&GT;
参考:
如果你要检查的内部运作,请参见:
-
CommonAnnotationBeanPostProcessor会
JavaDoc的,<一个href=\"http://grep$c$c.com/file/repository.springsource.com/org.springframework/org.springframework.context/3.0.4/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java\"相对=nofollow>来源$ C $ C -
ComponentScanBeanDefinitionParser
JavaDoc的,<一个href=\"http://grep$c$c.com/file/repository.springsource.com/org.springframework/org.springframework.context/3.0.4/org/springframework/context/annotation/ComponentScanBeanDefinitionParser.java\"相对=nofollow>来源$ C $ C
In case of supporting both XML and annotation, when spring framework do the annotation scan and how to process it?
Could someone give detail scenario?
For XmlWebApplicationContext, it use loadBeanDefinations() via Xml file. But when it do the annotation scan and use which class to process it?
Could explain the detail for ?
Thanks.
Franklin
解决方案
In an XML based Application Context, annotations are only registered if you explicitly configure that:
<!-- register default annotations (e.g. @Required) -->
<context:annotation-config />
<!-- scan for components in selected package -->
<context:component-scan base-package="org.example"/>
Reference:
And if you want to check the inner workings, see:
CommonAnnotationBeanPostProcessor
JavaDoc, Source CodeComponentScanBeanDefinitionParser
JavaDoc, Source Code
这篇关于Spring框架标注问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文