栀子栀子栀 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 github训练的模型参数无法下载
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油