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必需添加该依赖。这次因为这个地方忽视,造成调错花费了不少时间,记录下来加深记忆!

  • 相关阅读:
    OpenDiscussion_DataDrivenDesign
    WPF Auto LogOff
    Visual Studio模板
    我的TDD实践---UnitTest单元测试
    我的TDD实践---TDD概念篇
    我的TDD实践---SVN架设篇
    我的TDD实践---CI持续集成
    CSharpThinking---C#版本总结(附加三)
    CsharpThinking---代码契约CodeContract(八)
    c++文件偏移
  • 原文地址:https://www.cnblogs.com/dw039/p/14118704.html
Copyright © 2011-2022 走看看