Connection is read-only. Queries leading to data modification are not allowed 解决方法

时间:2025-03-18 09:03:56

错误描述

调用save()方法报错 Connection is read-only. Queries leading to data modification are not allowed

产生原因

让所有的方法都加入事务管理,类前面加了注解 @Transactional(readOnly = true)

设置为只读的事务,但是增删改就会报错 Connection is read-only.

解决方法

方法设置,可读可写即可加上如下注解:

@Transactional(readOnly = false)

	@Transactional(readOnly = false)
	public void insertOrUpdateByIdCard(YwPerson ywPerson) {
		(ywPerson);
	}