报的错:
Messages:
`
Could not obtain transaction-synchronized Session for current thread
File: org/springframework/orm/hibernate5/SpringSessionContext.java
Line number: 133
配置Spring-text.xml如下
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- **********************************************Admin************************************************ -->
<bean id="AdminAction" class="com.lanou.admin4ZND.controllor.AdminAction" scope="prototype">
<property name="adminService" ref="AdminService"></property>
</bean>
<bean id="AdminService" class="com.lanou.admin4ZND.services.impl.AdminService">
<property name="adminDao" ref="AdminDao"></property>
</bean>
<bean id="AdminDao" class="com.lanou.admin4ZND.Dao.impl.AdminDao">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- **************************************************SESSIONFACTORY****************************************************************** -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!--注入数据源, -->
<property name="dataSource" ref="dataSource"></property>
<!-- 配置别的属性 -->
<property name="hibernateProperties">
<props>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
</props>
</property>
<property name="mappingLocations"
value="classpath:com/lanou/ssh/entity/mappings/*.hbm.xml"></property>
</bean>
<!-- *******************************************DATASOURCE********************************************************** -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/ZND?characterEncoding=utf-8&useSSL=false" />
<property name="user" value="root" />
<property name="password" value="root" />
<property name="maxPoolSize" value="30"></property>
<property name="minPoolSize" value="5" />
<property name="acquireIncrement" value="1"></property>
</bean>
<!-- ************************************TRANSCATION********************************************* -->
<!-- 配置transactionManager -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="logicTx" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" timeout="-1"
read-only="false" rollback-for="java.long.Exception" isolation="DEFAULT" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="query*" propagation="REQUIRED" />
<tx:method name="select*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- ******************************************AOP********************************************** -->
<aop:config>
<!-- 配置切点 -->
<aop:pointcut expression="execution(* com.lanou.ssh.service.impl.*.*(..))"
id="pointcut" />
<!-- 通知 -->
<aop:advisor advice-ref="logicTx" pointcut-ref="pointcut" />
</aop:config>