SPring管理Hibernate事务出现异常处理

来源:互联网 时间:1970-01-01

[html] 

 出现以下错误:

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

解决方案:1、判断是否已包含管理

                          解决方法:

                            将事务中添加所监听的类

                   2、是否为SpringMVC+Hibernate架构:

                             解决办法:

                                  1.如果你将所有控制器放在一个包下,配置文件加入:

                                            <context:component-scan base-package="com.web.controllers"/>

                                  2.如Controller, Service, DAO在不同包package下。配置文件加入:

                                          <context:component-scan base-package="com.web" use-default-filters="false">

                                             <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>

                                           </context:component-scan>

 

相关阅读:
Top