错误信息为:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in file [F:\eclipse\ec_wp\SpringProgramming0300
\bin\com\spring\service\UserService.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'txAdvice': Cannot resolve reference to bean 'txManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:org/hibernate/engine/SessionFactoryImplementor
\bin\com\spring\service\UserService.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'txAdvice': Cannot resolve reference to bean 'txManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'txManager' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError:org/hibernate/engine/SessionFactoryImplementor
原来:(hibernate3)
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="nestedTransactionAllowed" value="true" /></bean>
现在(
hibernate4)
//Try using the org.springframework.orm.hibernate4.HibernateTransactionManager
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="sessionFactory" ref="sessionFactory" />
</bean>
问题就解决了。