在配置DAO代理的时候
<!-- 定义DAO代理 -->
<bean id="addressDAOProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref local="addressDAO" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
出现如下错误:
Referenced bean 'addressDAO' not found
cvc-id.1: There is no ID/IDREF binding for IDREF 'addressDAO'.
问题原因:
配置DAO代理前面没有配置DAO或者配置错误:
<!-- 定义DAO -->
<bean id="AddressDAO" class="com.demo.hibernate.dao.AddressDAO">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
改为:
<bean id="addressDAO" class="com.demo.hibernate.dao.AddressDAO">
正确。