天天看點

Spring的事物配置

基于同僚搭好的SSH架構,在裡面添加點功能,寫完代碼,自己測試的時候發現在通過hibernateTemplate向資料庫添加資料時報錯:

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

原來是Spring的事物配置的問題,我忘了改掉同僚的applicationContext.xml檔案裡的Spring的事物配置:

同僚的配置:

<aop:config proxy-target-class="true">
	<aop:advisor
	pointcut="execution(* com.geowayg.*.service..*.*(..))"
	advice-ref="txAdvice" />
</aop:config>
           

我的配置:

<aop:config proxy-target-class="true">
	<aop:advisor
	pointcut="execution(* com.andy.service..*.*(..))"
	advice-ref="txAdvice" />
</aop:config>
           

因為我改掉了一些包,是以要寫自己的相關包的路徑。

繼續閱讀