如何解决“Spring Cloud LoadBalancer 当前正在使用默认缓存。您可以切换到使用 Caffeine 缓存”警告?

Thi*_*mal 5 java spring-boot caffeine caffeine-cache

如何解决Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it to the classpath.spring boot中的警告?

Thi*_*mal 8

将以下库添加到您的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>
Run Code Online (Sandbox Code Playgroud)

或者在你的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'
Run Code Online (Sandbox Code Playgroud)

您可以替换合适/最新版本的caffeine.

  • 您能详细说明一下这种依赖关系解决的问题吗?默认缓存有什么特别错误的地方?为什么 Spring Cloud 不像许多其他库那样默认使用 Caffeine? (18认同)