spring3.1 + hiberante4 的事务配置问题

applicationContext.xml内容如下:

<beans ...>
<!-- 扫描指定类包,处理spring注解 -->
<context:component-scan base-package="com.xxx.dao"></context:component-scan>
<context:component-scan base-package="com.xxx.service"></context:component-scan>

<!-- 配置hibernate -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
<property name="configLocations">
<value>WEB-INF/hibernate.cfg.xml</value>
</property>
</bean>

<bean id="transactionManager" 
class="org.springframework.orm.hibernate4.HibernateTransactionManager" >
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<tx:annotation-driven/>
</beans>

总是出现这个错误:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.service.UnknownUnwrapTypeException: Cannot unwrap to requested type [javax.sql.DataSource]

难道是因为我使用hibernate.cfg.xml进行sessionFactory初始化么?

posted @ 2012-05-03 16:13  hibernate4.1  阅读(2052)  评论(0编辑  收藏  举报