4 ehcache 配置
- 拷贝ehcache.xml文件到工程的resources目录下面
<?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../bin/ehcache.xsd"> <defaultCache overflowToDisk="true" eternal="false" maxElementsInMemory="1"/> <diskStore path="E:/cache" /> </ehcache>
备注:diskStore 路径需要修改成对应的磁盘位置或目录
- 修改mybatis的mapper配置文件
<cache type="org.mybatis.caches.ehcache.EhcacheCache" />
- 打开log日志信息
<?xml version="1.0" encoding="UTF-8" ?> <configuration debug="false"> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="debug"> <appender-ref ref="STDOUT"/> </root> <logger name="org" level="error" /> </configuration>
- 对象序列化
package com.sishuok.architecture1.common.vo; import com.sishuok.pageutil.Page; public class BaseModel implements java.io.Serializable { /** * */ private static final long serialVersionUID = 1L; private Integer uuid; private Page page = new Page(); public Page getPage() { return page; } public void setPage(Page page) { this.page = page; } public Integer getUuid() { return uuid; } public void setUuid(Integer uuid) { this.uuid = uuid; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BaseModel other = (BaseModel) obj; if (uuid == null) { if (other.uuid != null) return false; } else if (!uuid.equals(other.uuid)) return false; return true; } }
备注:所有的model都继承了BaseModel,因此只需要BaseModel实现序列化就可以了,参考以上代码
- 运行服务,查看Eclipse控制台日志信息