1.添加jar包
2.配置hibernate.cfg.xml ,
cache.provider_class
cache.use_second_level_cache
hibernate.cache.use_query_cache
3.etc目录,ehcache.xml文件复制到src
<defaultCache
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="120"
        timeToLiveSeconds="120"
        overflowToDisk="true"
        />
4.指定缓存策略
<class name="com.zzzy.ch2.Student" table="STUDENT">
        <cache usage="read-only"/>
  </class>