spring高手如内,关于配置事务出现的问题
前不久刚从hibernate2下升级到hibernate3下,结果发现事务配置部分不能再用了。
配置的代码是(把原来hibernate2的org.springframework.orm.hibernate.HibernateTransactionManager换成了org.springframework.orm.hibernate3.HibernateTransactionManager就不行了)
<bean id= "transactionManager " class= "org.springframework.orm.hibernate3.HibernateTransactionManager ">
<property name= "sessionFactory "> <ref local= "sessionFactory "/> </property>
</bean>
<bean id= "baseTxProxy " lazy-init= "true " class= "org.springframework.transaction.interceptor.TransactionProxyFactoryBean ">
<property name= "transactionManager ">
<ref bean= "transactionManager " />
</property>
<property name= "transactionAttributes ">
<props>
<prop key= "save* "> PROPAGATION_REQUIRED </prop>
<prop key= "remove* "> PROPAGATION_REQUIRED </prop>
<prop key= "del* "> PROPAGATION_REQUIRED </prop>
<prop key= "load* "> PROPAGATION_REQUIRED,readOnly </prop>
<prop key= "get* "> PROPAGATION_REQUIRED,readOnly </prop>
<prop key= "sel* "> PROPAGATION_REQUIRED,readOnly </prop>
<prop key= "insert* "> PROPAGATION_REQUIRED </prop>
<prop key= "update* "> PROPAGATION_REQUIRED </prop>
<prop key= "add* "> PROPAGATION_REQUIRED </prop>
</props>
</property>
</bean>
结果运行报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'abstractTxDefinition ' defined in ServletContext resource [/WEB-INF/config/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is
java.lang.IllegalArgumentException: 'target ' is required
java.lang.IllegalArgumentException: 'target ' is required
请问高人这是为什么呀?郁闷
------解决方案-------------------- <bean id= "txManager " class= "org.springframework.orm.hibernate3.HibernateTransactionManager ">
<property name= "sessionFactory " ref= "sessionFactory "/>
</bean>
<bean id= "recruiterAutospotService "
class= "org.springframework.transaction.interceptor.TransactionProxyFactoryBean ">
<property name= "transactionManager ">
<ref bean= "txManager "/>
</property>
<property name= "target ">
<ref bean= "recruiterAutospotServiceImpl "/>
</property>
<property name= "transactionAttributeSource ">
<ref bean= "transactionAttributeSource "/>
</property>
</bean>