• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
Y-wee
博客园    首页    新随笔    联系   管理     

简单配置hibernate二级缓存

简单配置hibernate二级缓存

  • 导入缓存jar包
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-ehcache -->
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>5.4.21.Final</version>
    </dependency>
  • 开启二级缓存
<!-- 开启 Hibernate 的二级缓存 -->
<property name="hibernate.cache.use_second_level_cache">true</property>
  • 配置encache
<!-- 引入 EhCache 的工具 -->
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
  • 指定使用二级缓存的类(根据实际情况)
<class-cache class="com.gec.domain.Employee" usage="read-only" />
记得快乐
posted @ 2020-10-12 18:29  Y-wee  阅读(149)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3