执行插入更新删除操作,“Connection is read-only. Queries leading to data modification are not allowed”的异常。

在使用SSM(Spring、SpringMVC、MyBatis)框架和MySQL数据库时,遇到执行更新操作时出现'Connection is read-only. Queries leading to data modification are not allowed'异常。问题源于Spring配置文件中事务管理的设置错误,将所有方法默认设为了只读事务,只有以insert*、delete*、update*开头的方法排除在外。通过检查发现事务配置中'update'拼写错误为'updata',修正后,文件下载并更新数据库记录功能恢复正常。
摘要由CSDN通过智能技术生成

所用框架ssm,数据库是mysql

最近在学习springmvc的时候,做文件下载的时候遇到了Connection is read-only. Queries leading to data modification are not allowed

网上查找原因发现是因为自己在spring配置文件中增加了事务管理,,这里我给业务层com.study.service.impl包下所有的类和方法添加了事物,除了已insert* 、delete*和update*方法开头的方法事务不是只读的其他都是只读的,

applicationContext.xml详细配置如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-3.2.xsd
        http://www.springframework.org/schema/tx
   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值