一、报错提示:
Cache configuration does not exist 'ServletContext resource [ehcache.xml]
二、分析:
文件在项目里面,而且可以访问没有问题,原教程用的是.yml
格式,后来被我改为.properties
,可能就是格式错了。
三、原因:
用.yml
格式:
cache:
type: ehcache
ehcache:
config: config/ehcache.xml
用.properties
格式:
# ehcache配置文件地址
spring.cache.ehcache.config=classpath:config/ehcache.xml
原来是少写了classpath,难怪找不到
拓展:
1、 springboot默认的文件的加载路径:
/META-INF/resources/
/resources/
/static/
/public/
所以不在该路径下面的文件,就要自己讲文件路径添加到工程里面,用过classpath:config/ehcache.xml
的方式
总结:这是一个定位资源的入口