报错信息:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
beans.xml中的问题
<!-- 事务切面 -->
<bean id="tx" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="tm"></property>
<property name="transactionAttributes">
<props>
<prop key="reg">PROPAGATION_REQUIRED</prop>
<prop key="task_*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="tx" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="tm"></property>
<property name="transactionAttributes">
<props>
<prop key="reg">PROPAGATION_REQUIRED</prop>
<prop key="task_*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
加上红色部分语句就ok了!