首页 > 编程语言 > 详细

spring事务管理出错。No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

时间:2014-04-12 03:30:18      阅读:674      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url"
            value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <!--         连接池启动时的初始值 -->
<!--         <property name="initialSize" value="1" /> -->
        <!--         连接池的最大值 -->
<!--         <property name="maxActive" value="500" /> -->
        <!--         最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 -->
<!--         <property name="maxIdle" value="2" /> -->
        <!--          最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 -->
<!--         <property name="minIdle" value="1" /> -->
    </bean>


    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mappingResources">
            <list>
                <value>com/sys/model/model.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.hbm2ddl.auto=update
                hibernate.show_sql=true
                hibernate.format_sql=false
                hibernate.cache.use_second_level_cache=false
                hibernate.cache.use_query_cache=false
            </value>
        </property>
    </bean>
    
    <!-- 事务相关控制 -->
    <bean id="txManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRED" read-only="false"></tx:method>
        </tx:attributes>
    </tx:advice>
    
    <!--把事务控制在Service层 -->
    <aop:config>
        <aop:pointcut id="pc"
            expression="execution(public * com.sys.service.*.*(..))" />
        <aop:advisor pointcut-ref="pc" advice-ref="txAdvice" />
    </aop:config>
bubuko.com,布布扣

上面是配置文件,但是总是出现No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here。这个错误。到现在还没有解决!今晚就看看能不能解决吧!

spring事务管理出错。No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here,布布扣,bubuko.com

spring事务管理出错。No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

原文:http://www.cnblogs.com/shenghaishiweini/p/3659348.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!