Hibernate4.x与Spring3.x整合,初始化时报Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.SessionFactoryImplementor错误。
applicationContext.xml配置文件部分如下:
<!-- 定义事务管理器(声明式的事务) -->
<bean id="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
<tx:method name="is*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="interceptorPointCuts"
expression="execution(* biz.impl.*BizImpl.*(..))" />
<aop:advisor advice-ref="txAdvice"
pointcut-ref="interceptorPointCuts" />
</aop:config>
出现错误并不是应为缺少jar包,而是因为目前spring3.x已经支持hibernate4.x,故只需将class="org.springframework.orm.hibernate3.HibernateTransactionManager"改为class="org.springframework.orm.hibernate4.HibernateTransactionManager"即可