How to solve Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it to the classpath.
warning in spring boot?
Asked
Active
Viewed 7,774 times
10

Thirumal
- 8,280
- 11
- 53
- 103
-
How to disable it entirely please? – PatPanda Dec 17 '20 at 12:45
-
@PatPatPat, just set `spring.cloud.loadbalancer.cache.enabled=false`. See this reference chapter for details: https://docs.spring.io/spring-cloud-commons/docs/3.0.2/reference/html/index.html#loadbalancer-cache-configuration – Toparvion Mar 23 '21 at 09:10
3 Answers
8
Add the below library in your pom.xml
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.8.8</version>
</dependency>
or in your build.gradle
// https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine
compile group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.8.8'
You can replace the suitable/latest version of caffeine
.

Thirumal
- 8,280
- 11
- 53
- 103
-
17Can you please elaborate on the problem that this dependency solves? What is particularly wrong with the default cache? And why Spring Cloud doesn't use Caffeine by default as with many other libraries? – Toparvion Mar 23 '21 at 05:15
-
1somebody an idea why the latest version (3.0.x) of coffeine can't be used. Otherwise the warning is logged again. – sge Apr 21 '22 at 10:59
-
This is the right solution because it's not necessary to add spring-boot-starter-cache since it's already included in spring-cloud-starter-loadbalancer. – baronKarza Dec 14 '22 at 13:39
-
1@Toparvion As Spring itself says: "This cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath." I hope this help. – Askar Dec 17 '22 at 11:01
3
Spring Boot: Adding the following dependencies in the pom.xml
will be adequate:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

Askar
- 544
- 1
- 6
- 17
0
Try to add the below library in your pom.xml
.
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.19</version>
</dependency>

haiqiang
- 1
- 1
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 07 '22 at 23:05