报错详情

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/EhCacheCacheConfiguration.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheCacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/EhCacheCacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.sf.ehcache.CacheManager]: Factory method 'ehCacheCacheManager' threw exception; nested exception is java.lang.IllegalArgumentException: Cache configuration does not exist 'class path resource [ehcache.xml]'at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.9.jar:5.3.9]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.9.jar:5.3.9]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.4.jar:2.5.4]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.5.4.jar:2.5.4]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) [spring-boot-2.5.4.jar:2.5.4]at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) [spring-boot-2.5.4.jar:2.5.4]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) [spring-boot-2.5.4.jar:2.5.4]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) [spring-boot-2.5.4.jar:2.5.4]at com.itheima.Springboot19CacheApplication.main(Springboot19CacheApplication.java:13) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ehCacheCacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/EhCacheCacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.sf.ehcache.CacheManager]: Factory method 'ehCacheCacheManager' threw exception; nested exception is java.lang.IllegalArgumentException: Cache configuration does not exist 'class path resource [ehcache.xml]'at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1334) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.9.jar:5.3.9]... 19 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.sf.ehcache.CacheManager]: Factory method 'ehCacheCacheManager' threw exception; nested exception is java.lang.IllegalArgumentException: Cache configuration does not exist 'class path resource [ehcache.xml]'at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.9.jar:5.3.9]at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.9.jar:5.3.9]... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: Cache configuration does not exist 'class path resource [ehcache.xml]'at org.springframework.util.Assert.isTrue(Assert.java:139) ~[spring-core-5.3.9.jar:5.3.9]at org.springframework.boot.autoconfigure.cache.CacheProperties.resolveConfigLocation(CacheProperties.java:110) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]at org.springframework.boot.autoconfigure.cache.EhCacheCacheConfiguration.ehCacheCacheManager(EhCacheCacheConfiguration.java:54) ~[spring-boot-autoconfigure-2.5.4.jar:2.5.4]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_251]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_251]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_251]at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_251]at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.9.jar:5.3.9]... 34 common frames omitted

创建idea的项目为web工程,启动一直报错。报错说,找不到配置文件。

Cache configuration does not exist 'class path resource [ehcache.xml]'

后来把yml文件config的地方改为如下:

 cache:type: ehcacheehcache:config: classpath:ehcache.xml

发现还是启动报错,错误如上。我发现ehcache.xml和application.yml在同一层目录下,不管怎么改,都一直报错。

后来,我将ehcache.xml拖动到config下,然后application.yml改为如下:

  cache:type: ehcacheehcache:config: classpath:config/ehcache.xml

启动成功。

后来拖动ehcache.xml,跟application.yml平级,依然启动成功,奇怪了,到底是哪里的原因呢?

具体原因,知道的小伙伴可以在评论区告诉大家。

Cache configuration does not exist ‘ServletContext resource [/ehcache.xml]‘相关推荐

  1. Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]【解决方案】

    第一次自学springmvc的时候,老是报错Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml],郁闷的不要不 ...

  2. class path resource [beans.xml] cannot be opened because it does not exist

    严重: Exception sending context initialized event to listener instance of class org.springframework.we ...

  3. SSM中 出现错误 Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

    错误信息描述: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML docu ...

  4. 【JAVA错误笔记】 - 【Could not open ServletContext resource [/WEB-INF/applicationContext.xml]解决方法】

    [JAVA错误笔记] - [Could not open ServletContext resource [/WEB-INF/applicationContext.xml]解决方法] 参考文章: (1 ...

  5. class path resource [logback.xml] cannot be resolved to URL because it does not exist 问题解决

    class path resource [logback.xml] cannot be resolved to URL because it does not exist 问题解决 参考文章: (1) ...

  6. mvc报错template: “ServletContext resource [/WEB-INF/templates/index.html]“

    HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateIn ...

  7. 错误:Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]

    当在打包war时所遇到的错误: **Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [ ...

  8. spring报错parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]

    一. 报错如下: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML doc ...

  9. 关于“Could not open ServletContext resource [/WEB-INF/applicationContext.xml]”解决方案

    问题产生 最近学了Maven,并尝试将以前的项目(springmvc+myabtis)重构成Maven项目,Maven项目推荐各种资源文件都放在src/java/resources目录下,所以我自然把 ...

最新文章

  1. pycharm debug code -1073741819
  2. python contains_Python中有判断字符串包含(contains)子串的方法吗?
  3. mysql表大小限制_技术分享 | 在磁盘上查找 MySQL 表的大小
  4. HashMap 面试常见的6连问,你能扛得住吗?
  5. Python实现二叉树的三种深度遍历方法!
  6. java 数字的进制转换
  7. debian 安装_如何在 Debian/Ubuntu 系统中检查程序包是否安装?
  8. java 调用mysql视图_如何在java spring POJO类上注入和使用mysql视图代替表 . 是否可以使用视图...
  9. UML类图画法全程解析
  10. 期货和股票平仓时成本计价的区别(期货和股票平仓时成本计价的区别是什么)
  11. 设置Mysql数据库的默认编码为utf8
  12. HTML之调色原理分析
  13. 无线路由器无法在计算机上设置,无线路由器设置管理地址无法打开解决方法
  14. 2019软考备战:软考中级课程+参考资料
  15. P1456 Monkey King 左偏树模板题
  16. 5、Spring SPEL使用之--在XML中使用SPEL
  17. linux定时关机命令_软件设计师必知Linux命令 | 推荐收藏~
  18. 使用Vim编辑运行shell脚本文件的经典步骤
  19. 1034 有理数四则运算 (20分)
  20. 经济学计算机会成本,经济学思维方式之二——机会成本、经济利润

热门文章

  1. GitKraken Pro安装
  2. 干货 | 浅谈携程大住宿研发效能提升实践
  3. 基于深度学习Autoencoder的信用卡欺诈异常检测算法
  4. 字符检测CTPN的tensorflow实现
  5. 【致敬未来的攻城狮计划】— 连续打卡第三天:欲速则不达,今天是对RA2E1 基础知识的补充学习。
  6. 【IIS】网页HTTP错误 404.3 - Not Found解决方案
  7. 办事大厅导航系统—业务智能导办—智慧政务建设
  8. AlexNet网络结构详解(含各层维度大小计算过程)与PyTorch实现
  9. 前端和后端终极学习视频(百度网盘资料)
  10. Divi Builder v4.1- 超级网页拖拽建站神器