栀子栀子栀 2015-03-18 06:50 采纳率: 0%
浏览 4513

求解决No Hibernate Session bound to thread

ssh项目在运行时控制台没有出错,但是页面出现
HTTP Status 500 - No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here怎么解决???
图片说明

applicationContext.xml文件配置如下:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">









<property name="maxActive" value="100"></property>  

<property name="maxIdle" value="30"></property>  

<property name="maxWait" value="500"></property>  

<property name="defaultAutoCommit" value="true"></property>  

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.MySQLDialect
            </prop>
        </props>
    </property>

    <property name="mappingResources">
        <list>
            <value>vo/News.hbm.xml</value></list>
    </property></bean>

class="org.springframework.orm.hibernate3.HibernateTransactionManager">



tx:attributes
<!-- 只有一save、delete、update开头的方法才能执行增删改操作 -->


<!-- 其他方法为只读方法 -->
/tx:attributes
/tx:advice

aop:config
<!-- 对应实现类接口的包的位置 -->

/aop:config

<!-- 业务层Service -->
<bean id="news_service" class="service.impl.NewsServiceImpl">
    <property name="sessionFactory">
         <ref bean="sessionFactory"></ref>
    </property>
</bean>

<!-- 控制层Action -->
<bean id="news_action" class="action.NewsAction">
    <property name="news_services">
         <ref bean="news_service" />
    </property>
</bean>
    </beans>



    初学ssh的菜鸟,请各位大神帮忙解答一下!!谢谢!
  • 写回答

3条回答 默认 最新

  • 不一样的人 2015-03-19 07:46
    关注

    出现这个情况是对新版本的hibernate框架了解不熟悉导致的,新版本的hibernate要求开发者必须配置事务管理,因为session的创建和销毁都是被事务管理的。出现则种情况,是你的事务管理没有配置好

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog