基本上,我有需要成为实体的对象,但代码是生成的,我无法触及它(因此我无法使用注释)。我想在xml配置中列出它们。但是,我也喜欢spring自动发现并自动发送相应的daos。我该如何设置配置?
答案 0 :(得分:2)
您可以按照自己的喜好配置组件扫描(顺便说一句:您可以进行多次组件扫描)
<context:component-scan base-package="org.example" use-default-filters="false">
<context:include-filter type="regex" expression=".*Dao"/>
</context:component-scan>
此示例将为与正则表达式匹配的所有类创建bean,并且位于基础包中。
@See S pring Reference Chapter 3.10.3 Using filters to customize scanning