InvalidDataAccessApiUsageException SpringMVC Spring Hibernate 整合

在整合SpringMVC、Spring和Hibernate时遇到InvalidDataAccessApiUsageException,错误提示写操作在只读模式下不允许。问题源于重复扫描导致的两个bean工厂。解决方案是确保在配置文件中的<context:component-scan>标签的base-package不重复,避免创建两个bean工厂。若尝试通过web.xml配置filter解决,可能会引发新的严重异常。
严重: Servlet.service() for servlet [springMVC] in context with path [/ssMVCh] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.] with root cause

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


听说SpringMVC和Spring 是无缝整合的,,,然后 springMVC-servlet.xml 和 applicationContext.xml 中都配置扫描,,然后扫描的包又是重复的,,然后就是两个bean工厂,,,然后异常,,,无缝整合,说说而已吧!

So........两个.xml文件中的<context:component-scan base-package="com..........." />     扫描的包是不能重复的!


如果采用web.xml中配置filter  的方式来解决该异常,又会产生一个你终身难忘的传说中的异常!



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值