将Spring Boot从1.5.12迁移到1.5.13后,ehcache提供错误

Mun*_*del 3 spring-boot spring-cache

我已经配置了Spring Boot 1.5.12 + ehcache,一切正常,直到我将Spring Boot升级到1.5.13

application.yml 具有以下条目

spring:
  cache:
    jcache:
      provider: org.ehcache.jsr107.EhcacheCachingProvider
      config: ehcache.xml
Run Code Online (Sandbox Code Playgroud)

ehcache.xml位于resources目录下

我收到的错误是:

Caused by: java.lang.IllegalArgumentException: Cache configuration does not exist 'ServletContext resource [/ehcache.xml]'
    at org.springframework.util.Assert.isTrue(Assert.java:92)
    at org.springframework.boot.autoconfigure.cache.CacheProperties.resolveConfigLocation(CacheProperties.java:117)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.createCacheManager(JCacheCacheConfiguration.java:113)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration.jCacheCacheManager(JCacheCacheConfiguration.java:97)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.CGLIB$jCacheCacheManager$1(<generated>)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047$$FastClassBySpringCGLIB$$a6ae7187.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
    at org.springframework.boot.autoconfigure.cache.JCacheCacheConfiguration$$EnhancerBySpringCGLIB$$e5c3a047.jCacheCacheManager(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 47 common frames omitted
Run Code Online (Sandbox Code Playgroud)

看来Spring Boot已开始搜索ehcache.xml使用ServletContext解析器。

ps:除了将Spring Boot升级到1.5.13之外,我没有任何源代码更改

我在这里缺少一些必需的配置吗?

Mun*_*del 6

我已经找到解决此问题的方法。我们需要classpath:使用文件名指定前缀以使其起作用。

application.yml现在看起来像这样

spring:
   cache:
     jcache:
        provider: org.ehcache.jsr107.EhcacheCachingProvider
        config: classpath:ehcache.xml
Run Code Online (Sandbox Code Playgroud)

希望能有所帮助。