严重: 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 的方式来解决该异常,又会产生一个你终身难忘的传说中的异常!
在整合SpringMVC、Spring和Hibernate时遇到InvalidDataAccessApiUsageException,错误提示写操作在只读模式下不允许。问题源于重复扫描导致的两个bean工厂。解决方案是确保在配置文件中的<context:component-scan>标签的base-package不重复,避免创建两个bean工厂。若尝试通过web.xml配置filter解决,可能会引发新的严重异常。
4万+

被折叠的 条评论
为什么被折叠?



