Home > Software engineering >  Spring Boot Upgrade from 2.6.x to 2.7.0
Spring Boot Upgrade from 2.6.x to 2.7.0

Time:08-05

I have upgraded Spring Boot version from 2.6.9 to 2.7.0 we were getting below error. java.lang.IllegalArgumentException: cannot find cache Named "cacheName"

pom.xml:

   <dependency> 
     <groupid>net.sf.ehcache</>
     <artifactId>ehcache</>
  </dependency>

ehcache.xml:

     <cache name="cacheName" logging="true" maxelementsinmemory="1000" eternal="false" 
        overflowtodisck="false" timetoidleseconds="300" timetoliveseconds="300" 
     memorystorevictionpolicy="LFU"/>
JAVA Method:

   @Cacheable("cacheName")
     public List getValues(){
     return list;
  }

Defined @EnableCaching at below class

@SpringBootApplication 
@EnableCachong
public class Application extends SpringBootInitializer{
}

CodePudding user response:

I'm not seeing any cache configuration in your code snippets. Is the cache implementation supposed to create the cache automatically?

Your application should declare the cache name like this:

spring.cache.cache-names=cacheName

Also, see this issue which might explain the change of behavior.

  • Related