两个Springboot应用在同一台服务器上运行,用
hibernate更新相同表实体记录时,发生
class="java" name="code">org.springframework.orm.hibernate4.HibernateSystemException: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000; nested exception is org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: java.io.StreamCorruptedException: invalid stream header: 00000000
at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:218)
at org.springframework.orm.hibernate4.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:730)
at org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:592)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
异常,经过排查
发现是因为ehache缺省配置是持久化
硬盘的,而两个项目的cache存储路径相同,导致反
序列化时发生
错误。
修改ehcache.xml,设置缺省cache的diskPersistent="false"即可。