i tried using this in spring 3 xml file but it gives error
<tx:annotation-driven transaction-manager="transactionManager" />
what thinga are required for this to work
You need a transactionManager, eg,
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
Which requires a SessionFactory which in turn requires a DataSource (here c3p0):
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
...
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
...
</bean>
You also need to declare your transactions. I personally prefer the declarative transaction approach where you simply annotate your database routines with @Transactional .
您需要将cglib-nodep-2.1_3.jar aopalliance-1.0.jar添加到您的类路径中,并将xmlns:tx =“ http://www.springframework.org/schema/tx添加到applicationContext.xml定义中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.