Spring+Hibernate4 发生异常Turn your Session into FlushMode.COMMIT/AUTO...
2016-11-27 11:43
288 查看
我的Project 是 Structs2+Spring+Hibernate4
我的错误是 serviceImpl上没有加 @Transactional 注解,之前好多方法配置web.xml文件的,误导了好久。
Spring的配置文件
Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
我的错误是 serviceImpl上没有加 @Transactional 注解,之前好多方法配置web.xml文件的,误导了好久。
import org.springframework.transaction.annotation.Transactional; @Transactional public class DepartmentServiceImpl ....
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>SSH_employeepeng</display-name> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
Spring的配置文件
applicationContext.xml
<!-- 配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 开启事务注解 --> <tx:annotation-driven transaction-manager="transactionManager" />
相关文章推荐
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or rem
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly'
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- 报错原因 (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker fr
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definitio
- [hibernate]Turn your Session into FlushMode.COMMIT/AUTO,请教这种配置怎么处理
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- spring出现 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marke问题
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- [SSH] Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- 两种方法解决Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker
- Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition
- 解决 Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AU