org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
来源:互联网 发布:微信聊天记录迁移 mac 编辑:程序博客网 时间:2024/05/15 18:10
最近遇到如题的这个问题, 解决了好几个小时都是无果,自己百度,都是说在web.xml中加上一段filter就可以,但是我的搞了好久,依旧不行,今天早上再次查找资料的时候,终于解决了,先说一下,强烈建议以后有问题的可以上 http://stackoverflow.com/看看,虽然看上去都是英语,但是稍微有点基础还是都能看懂的,关键不要慌,而且主要看代码,所以这是一个非常棒的社区,强烈推荐
我的问题就如题目所说的样子,关键,而且百度上的都解决不了,先说我的解决方式。我在web.xml中没有加filter
我的web.xml是这样的:和普通的写法一样
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 用来定位Spring XML文件的上下文配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext*.xml</param-value> </context-param> <!-- 启动 Spring Bean 工厂的监听器--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 启动 Struts 2 的过滤器--> <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> <!-- 解决中文字符乱码 --> <filter><filter-name>Set Character Encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>utf-8</param-value></init-param><init-param><param-name>forceEncoding</param-name><param-value>true</param-value></init-param></filter> </web-app>
<!-- 配置spring的声明式事务 --> <!-- 1.配置hibernate的事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 2.配置事务属性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="*"/> </tx:attributes> </tx:advice> <!-- 3.配置事务切入点,再把事务属性和事务切入点关联起来 --> <aop:config> <aop:pointcut expression="execution(* com.service.*.*(..))" id="txPointCut"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/> </aop:config>
2.我的
<aop:pointcut expression="execution(* com.service.*.*(..))"这个的写法是我的service的包名字,我web project的构造如下:
我的service都是在com.service.serviceImp.java.中,所以这个地方按自己的工程需要改写,其他的地方几乎都是常规的,这样我的hibernateTemplate在执行基本操作的时候就没有报错了
由bug,年轻人,别慌,慢慢来,你要耗得的起
0 0
- [spring]:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER)
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed
- 异常积累:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in
- SSH框架org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in
- 异常积累:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in
- 异常积累:org.springframework.dao.InvalidDataAccessApiUsageException Write operations are not allowed in
- InvalidDataAccessApiUsageException:Write operations are not allowed in read-only mode
- git仓库迁移
- 链表的C++实现(int型) 源代码
- 蒲公英VPN智能组网服务新布局 助力服装企业VPN服务器架设
- app测试员究竟测些什么呢?
- Stack Overflow简单介绍
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- [bzoj1570][JSOI2008] Blue Mary的旅行 最大流
- SQL必知必会笔记手册
- k8s入门系列之guestbook快速部署
- php基础知识 10,数组的运用
- iOS JSModel转化过程中含有id属性解决办法
- Kali Linux下运行Sniffjoke出错的解决
- Android Tangram模型:连淘宝、天猫都在用的UI框架模型你一定要懂
- 场景解析--Pyramid Scene Parsing Network