http://xiangai.taobao.com
http://shop148612228.taobao.com

Cannot unwrap to requested type [javax.sql.DataSource]

遇上这个bug我的情况是这样,hibernate4以后,spring3.1不再有hibernateDaoSupport,在dao层不能继承HibernateDaoSupport,

只能显式声明SessionFactory,并且设置get/set方法。

不确定的说:

       在hibernate4以后,session管理变动较大,spring也变了,所以DataSource要在applicationContext.xml里面配置

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

<property name="dataSource" ref="dataSource"/>

...

</bean>

如果你在hibernate.cfg.xml里面配置了,就会报出Cannot unwrap to requested type [javax.sql.DataSource]错误。

posted @ 2014-03-23 08:26  万事俱备就差个程序员  阅读(371)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏