Caching Spring引导缓存无法为生成器解析缓存

Caching Spring引导缓存无法为生成器解析缓存,caching,spring-boot,Caching,Spring Boot,根据,在spring boot中使用缓存的最简单配置是使用CacheManager(缓存映射将在此类中初始化): 在serviceImpl.java中: @Cacheable(cacheManager="guavaCacheManager") @Override public List<RoleVO> getDataForCreateNewOperator() { ... } 编辑: 如果我在cacheManager中分配cacheName,并在建议的方法中使用它,则异

根据,在spring boot中使用缓存的最简单配置是使用CacheManager(缓存映射将在此类中初始化):

serviceImpl.java
中:

 @Cacheable(cacheManager="guavaCacheManager")
 @Override
 public List<RoleVO> getDataForCreateNewOperator() {
  ...
 }
编辑:
如果我在cacheManager中分配cacheName,并在建议的方法中使用它,则异常消失。但是bean中的所有方法都将被缓存,而我只在一个方法上分配了
@Cacheable

我正在使用Ehcache,我遇到了相同的问题,因为我有两个不同的 缓存和可缓存的名称

Please make you use same name for cache and Cacheable.

@Cacheable("codetable")

<cache name="codetable"
        maxEntriesLocalHeap="100"
        maxEntriesLocalDisk="1000"
        eternal="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="600"
        memoryStoreEvictionPolicy="LFU"
        transactionalMode="off">
        <persistence strategy="localTempSwap" />
    </cache>
请使缓存和可缓存使用相同的名称。
@可缓存(“代码表”)

您是否在您的存储库方法上尝试过类似的方法:@Cacheable(cacheNames=“cache name”)?@Afridi是的,我尝试过,效果不错。但不是动态的,它也应该起作用。此外,使用cacheName虽然异常已消失,但它使整个类可缓存,而不仅仅是方法。
java.lang.IllegalStateException: No cache could be resolved for 'Builder[public java.util.List getDataForCreateNewOperator()] caches=[] | key='' | keyGenerator='' | cacheManager='guavaCacheManager' | cacheResolver='' | condition='' | unless='' | sync='false'' using resolver 'org.springframework.cache.interceptor.SimpleCacheResolver@38466d10'. At least one cache should be provided per cache operation.
Please make you use same name for cache and Cacheable.

@Cacheable("codetable")

<cache name="codetable"
        maxEntriesLocalHeap="100"
        maxEntriesLocalDisk="1000"
        eternal="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="600"
        memoryStoreEvictionPolicy="LFU"
        transactionalMode="off">
        <persistence strategy="localTempSwap" />
    </cache>