关于Spring出现"COMMIT/AUTO or remove 'readOnly' marker from transaction definition."的解决办法

对数据库进行操作时报出了如下的错误:

原因:对service没有配置事务的操作或配置之后没有为service添加注解

解决办法,在spring的xml中配置事务的相关部分:

1 <!-- 配置事务管理 -->
2     <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
3         <property name="sessionFactory" ref="sessionFactory"></property>
4     </bean>
5     
6     <!-- 开启事务管理 -->
7     <tx:annotation-driven transaction-manager="transactionManager"/>

最后不要忘记在service上添加注解:

原文地址:https://www.cnblogs.com/cuibin/p/6735428.html