zoukankan      html  css  js  c++  java
  • 备忘 springboot 整合ehcache,注入CacheManager时提示 required a bean of type 'org.springframework.cache.CacheManager' that could not be found

    问题因人而异,此处仅做备忘

    整合过程:

    1、添加maven依赖

            <dependency>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
                <version>2.10.6</version>
            </dependency>

    2、开启springboot缓存

    @EnableCaching
    @SpringBootApplication
    public class EhcachetestApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(EhcachetestApplication.class, args);
        }
    
    }

    3、在使用位置注入 org.springframework.cache.CacheManager

    注:上面飘红并不是报错的原因,可忽略。

     4、打包测试,报 required a bean of type 'org.springframework.cache.CacheManager' that could not be found

    5、增加 spring-boot-starter-cache 依赖

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-cache</artifactId>
            </dependency>

    6、再次打包测试,一切OK

    问题原因分析:

    spring-boot-starter-cache 是springboot缓存功能的依赖,如果要开启springboot cache必需添加该依赖。这次因为这个地方忽视,造成调错花费了不少时间,记录下来加深记忆!

  • 相关阅读:
    小程序配置安装
    微信小程序--录制音频,播放音频
    微信小程序报错.wxss无法找到
    linux 安装 elasticsearch
    Ubuntu 安装Logstash
    python 开发微信 自定义菜单
    微信 python搭建服务器
    vue 本地存储数据 sessionStorage
    luogu1742 最小圆覆盖
    luogu1501 [国家集训队]Tree II
  • 原文地址:https://www.cnblogs.com/dw039/p/14118704.html
Copyright © 2011-2022 走看看