ssm用ehcache会出现的错误

来源:互联网 发布:python re 匹配域名 编辑:程序博客网 时间:2024/06/05 05:46

其他地方的配置可以看其他文章

mapper.xml

<mapper namespace="com.carry.ssm.Dao.UserMapper">
<cache></cache>  //这句话必须加,否则缓存不起作用


<!-- <cache readOnly="true">
  <property name="timeToIdleSeconds" value="3600"/>1 hour  
    <property name="timeToLiveSeconds" value="3600"/>1 hour  
    <property name="maxEntriesLocalHeap" value="1000"/>  
    <property name="maxEntriesLocalDisk" value="10000000"/>  
    <property name="memoryStoreEvictionPolicy" value="LRU"/>  
  </cache>
 -->


<!-- 在mapper.xml这样设置了默认是全部操作都会执行缓存策略,如果有某些sql不需要执行,可以把useCache设置为false。
<select id="selectUser" resultMap="BaseResultMap" parameterType="XX.XX.XX.XX.User" useCache="false" > -->


当运行的时候,突然报了个错误,其中有句话:

org.apache.ibatis.cache.CacheException: Error serializing object

就是错误的序列化对象,原因是在Model的对象必须实现序列化接口,

public class User implements Serializable{

省略其他代码.......

}

成功运行,第一次访问数据库,第二次从缓存读取数据




0 0
原创粉丝点击