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

 

出现以下错误:

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>
                                      

 

posted @ 2013-06-08 20:13  爱生活,爱编程  阅读(280)  评论(0编辑  收藏  举报