【发布时间】:2012-03-14 18:56:48
【问题描述】:
基本上,我有需要成为实体的对象,但是生成了代码并且我无法触摸它(因此我无法使用注释)。我想在 xml 配置中列出它们。但是,我也希望 spring 自动发现和自动连接各自的 daos。我将如何设置我的配置?
【问题讨论】:
标签: spring hibernate jpa annotations autowired
基本上,我有需要成为实体的对象,但是生成了代码并且我无法触摸它(因此我无法使用注释)。我想在 xml 配置中列出它们。但是,我也希望 spring 自动发现和自动连接各自的 daos。我将如何设置我的配置?
【问题讨论】:
标签: spring hibernate jpa annotations autowired
您可以根据需要配置组件扫描(顺便说一句:您可以进行多个组件扫描)
<context:component-scan base-package="org.example" use-default-filters="false">
<context:include-filter type="regex" expression=".*Dao"/>
</context:component-scan>
此示例将为所有匹配正则表达式并位于基础包中的类创建 bean。
@见Spring Reference Chapter 3.10.3 Using filters to customize scanning
【讨论】: