【发布时间】:2011-12-21 16:28:47
【问题描述】:
在我的 spring dao 配置 xml 中,我目前必须手动列出域类名称。有没有什么办法可以自动化这个过程,以消除在创建新域类时手动列出域类的需要?
为了更好地了解我想要做什么,使用类似于组件扫描或类似的东西
当前代码
<bean id="daoSessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="applicationDataSource" />
<property name="annotatedClasses">
<list>
<value>com.greenwhich.application.domain.Driver</value>
<value>com.greenwhich.application.domain.DriverRealTimeCurrentLocation</value>
<value>com.greenwhich.application.domain.Journey</value>
<value>com.greenwhich.application.domain.Customer</value>
<value>com.greenwhich.application.domain.SystemConstants</value>
<value>com.greenwhich.application.domain.DriverRequest</value>
<value>com.greenwhich.application.domain.Account</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
我只要求自动检测“annotatedClasses”属性下的值
有什么方法可以实现吗?到目前为止,我已经尝试在“annotatedClasses”属性中插入组件扫描,以搜索不起作用的“Entity”注释
非常感谢任何帮助
【问题讨论】:
标签: java hibernate spring dependency-injection