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

<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>

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

上一篇:maven中的java库


下一篇:报错解决:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here