Spring Cloud Feign--解决spring-cloud-loadbalancer的缓存警告

2年前 (2022) 程序员胖胖胖虎阿
199 0 0

原文网址:Spring Cloud Feign--解决spring-cloud-loadbalancer的缓存警告_IT利刃出鞘的博客-CSDN博客

简介

说明

        本文解决spring-cloud-loadbalancer的缓存相关的警告。

问题描述

项目启动时报警告:

2022-05-04 09:19:52.267  WARN 4464 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.

调feign时报警告:

2022-05-04 09:29:05.005  WARN 4464 --- [nio-9012-exec-1] c.l.c.ServiceInstanceListSupplierBuilder : LoadBalancerCacheManager not available, returning delegate without caching.

依赖的版本

  1. spring-boot-starter-parent:2.4.13
  2. spring-cloud-dependencies:2020.0.1
  3. spring-cloud-loadbalancer:3.0.1

问题复现

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.13</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>
    <groupId>com.knife</groupId>
    <artifactId>parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>2020.0.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.24</version>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            <exclusions>
                <exclusion>
                    <groupId> springframework.cloud</groupId>
                    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-loadbalancer</artifactId>
        </dependency>
    </dependencies>
    
</project>

输出的日志

D:\dev\Java\jdk1.8.0_201\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:61282,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\Liu\AppData\Local\Temp\captureAgent8443jars\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\dev\Java\jdk1.8.0_201\jre\lib\charsets.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\deploy.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\access-bridge-64.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\cldrdata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\dnsns.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jaccess.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\localedata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\nashorn.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunec.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunjce_provider.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunmscapi.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunpkcs11.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\zipfs.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\javaws.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jce.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfr.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfxswt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jsse.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\management-agent.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\plugin.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\resources.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\rt.jar;E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\account\account-api\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\storage\storage-api\target\classes;E:\work\maven\repository\org\springframework\boot\spring-boot-starter\2.4.13\spring-boot-starter-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot\2.4.13\spring-boot-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.4.13\spring-boot-autoconfigure-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.4.13\spring-boot-starter-logging-2.4.13.jar;E:\work\maven\repository\ch\qos\logback\logback-classic\1.2.7\logback-classic-1.2.7.jar;E:\work\maven\repository\ch\qos\logback\logback-core\1.2.7\logback-core-1.2.7.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\work\maven\repository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;E:\work\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\work\maven\repository\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;E:\work\maven\repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;E:\work\maven\repository\org\springframework\spring-core\5.3.13\spring-core-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-jcl\5.3.13\spring-jcl-5.3.13.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-config\2021.1\spring-cloud-starter-alibaba-nacos-config-2021.1.jar;E:\work\maven\repository\com\alibaba\spring\spring-context-support\1.0.10\spring-context-support-1.0.10.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-client\1.4.1\nacos-client-1.4.1.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-common\1.4.1\nacos-common-1.4.1.jar;E:\work\maven\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;E:\work\maven\repository\org\apache\httpcomponents\httpasyncclient\4.1.4\httpasyncclient-4.1.4.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore-nio\4.4.14\httpcore-nio-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-api\1.4.1\nacos-api-1.4.1.jar;E:\work\maven\repository\com\google\guava\guava\24.1.1-jre\guava-24.1.1-jre.jar;E:\work\maven\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;E:\work\maven\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;E:\work\maven\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;E:\work\maven\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;E:\work\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;E:\work\maven\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;E:\work\maven\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-commons\3.0.1\spring-cloud-commons-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-crypto\5.4.9\spring-security-crypto-5.4.9.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-context\3.0.1\spring-cloud-context-3.0.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2021.1\spring-cloud-starter-alibaba-nacos-discovery-2021.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2021.1\spring-cloud-alibaba-commons-2021.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-loadbalancer\3.0.1\spring-cloud-loadbalancer-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-validation\2.4.13\spring-boot-starter-validation-2.4.13.jar;E:\work\maven\repository\org\glassfish\jakarta.el\3.0.4\jakarta.el-3.0.4.jar;E:\work\maven\repository\org\hibernate\validator\hibernate-validator\6.1.7.Final\hibernate-validator-6.1.7.Final.jar;E:\work\maven\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;E:\work\maven\repository\org\jboss\logging\jboss-logging\3.4.2.Final\jboss-logging-3.4.2.Final.jar;E:\work\maven\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;E:\work\maven\repository\io\projectreactor\reactor-core\3.4.12\reactor-core-3.4.12.jar;E:\work\maven\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\work\maven\repository\io\projectreactor\addons\reactor-extra\3.4.5\reactor-extra-3.4.5.jar;E:\work\Idea_proj\router4j\router4j-example\common\target\classes;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-web\2.4.13\spring-boot-starter-web-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-json\2.4.13\spring-boot-starter-json-2.4.13.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.4.13\spring-boot-starter-tomcat-2.4.13.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.55\tomcat-embed-core-9.0.55.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.55\tomcat-embed-websocket-9.0.55.jar;E:\work\maven\repository\org\springframework\spring-web\5.3.13\spring-web-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-beans\5.3.13\spring-beans-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-webmvc\5.3.13\spring-webmvc-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-aop\5.3.13\spring-aop-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-context\5.3.13\spring-context-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-expression\5.3.13\spring-expression-5.3.13.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter-openfeign\3.0.1\spring-cloud-starter-openfeign-3.0.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter\3.0.1\spring-cloud-starter-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;E:\work\maven\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;E:\work\maven\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-openfeign-core\3.0.1\spring-cloud-openfeign-core-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.4.13\spring-boot-starter-aop-2.4.13.jar;E:\work\maven\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form-spring\3.8.0\feign-form-spring-3.8.0.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form\3.8.0\feign-form-3.8.0.jar;E:\work\maven\repository\commons-fileupload\commons-fileupload\1.4\commons-fileupload-1.4.jar;E:\work\maven\repository\io\github\openfeign\feign-core\10.10.1\feign-core-10.10.1.jar;E:\work\maven\repository\io\github\openfeign\feign-slf4j\10.10.1\feign-slf4j-10.10.1.jar;E:\work\maven\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.3\lib\idea_rt.jar" com.knife.order.OrderApplication
Connected to the target VM, address: '127.0.0.1:61282', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.4.13)

2022-05-04 09:19:49.504  INFO 4464 --- [           main] com.knife.order.OrderApplication         : Starting OrderApplication using Java 1.8.0_201 on DESKTOP-QI6B9ME with PID 4464 (E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes started by Liu in E:\work\Idea_proj\router4j\router4j-example)
2022-05-04 09:19:49.506  INFO 4464 --- [           main] com.knife.order.OrderApplication         : No active profile set, falling back to default profiles: default
2022-05-04 09:19:50.218  INFO 4464 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=4536d57f-eca1-3e3b-a343-0d0a431ffdf8
2022-05-04 09:19:50.488  INFO 4464 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9012 (http)
2022-05-04 09:19:50.497  INFO 4464 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-05-04 09:19:50.497  INFO 4464 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-05-04 09:19:50.605  INFO 4464 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-05-04 09:19:50.605  INFO 4464 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1053 ms
2022-05-04 09:19:52.267  WARN 4464 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-05-04 09:19:52.456  INFO 4464 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9012 (http) with context path ''
2022-05-04 09:19:52.469  INFO 4464 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP order 192.168.0.102:9012 register finished
2022-05-04 09:19:53.038  INFO 4464 --- [           main] com.knife.order.OrderApplication         : Started OrderApplication in 4.551 seconds (JVM running for 5.572)
2022-05-04 09:29:04.913  INFO 4464 --- [nio-9012-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-05-04 09:29:04.913  INFO 4464 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-05-04 09:29:04.914  INFO 4464 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-05-04 09:29:04.950  INFO 4464 --- [nio-9012-exec-1] c.k.order.controller.OrderController     : 订单服务:创建订单:Order(id=null, userId=1, productId=1, count=10, money=100, status=null, createTime=null, updateTime=null)
2022-05-04 09:29:05.005  WARN 4464 --- [nio-9012-exec-1] c.l.c.ServiceInstanceListSupplierBuilder : LoadBalancerCacheManager not available, returning delegate without caching.
2022-05-04 09:29:05.067  WARN 4464 --- [nio-9012-exec-1] c.l.c.ServiceInstanceListSupplierBuilder : LoadBalancerCacheManager not available, returning delegate without caching.

原因分析

        通过警告信息,我们能定位到警告位置在LoadBalancerCacheAutoConfiguration这个配置类中,下面我们看下这个类干了哪些事儿。

/**
 * 一个自动配置,在Spring Boot启动时自动启用缓存Spring Framework缓存支持。
 * 如果类路径中存在Caffeine,则将用于负载均衡器缓存。否则,将使用默认缓存。
 *
 * @author Olga Maciaszek-Sharma
 * @since 2.2.0
 * @see CacheManager
 * @see CacheAutoConfiguration
 * @see CacheAspectSupport
 * @see <a href="https://github.com/ben-manes/caffeine>Caffeine</a>
 */
@Configuration(proxyBeanMethods = false) //proxyBeanMethods 默认是true,表示使用@Bean的类使用代理;此处不使用代理
@ConditionalOnClass({ CacheManager.class, CacheAutoConfiguration.class }) //装载这CacheManager、CacheAutoConfiguration两个bean
@AutoConfigureAfter(CacheAutoConfiguration.class) // 在CacheAutoConfiguration之后进行自动装配
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.cache.enabled", matchIfMissing = true)// 属性匹配
@EnableConfigurationProperties(LoadBalancerCacheProperties.class)//启用对@ConfigurationProperties注解bean的支持,此处是LoadBalancerCacheProperties
public class LoadBalancerCacheAutoConfiguration {

   @Configuration(proxyBeanMethods = false)//不使用代理
   @Conditional(OnCaffeineCacheMissingCondition.class)//Caffeine缓存丢失条件,如果没有引入caffeine,符合则加载这个bean,输出日志
   protected static class LoadBalancerCacheManagerWarnConfiguration {

      @Bean
      LoadBalancerCaffeineWarnLogger caffeineWarnLogger() {
         // caffeine警告日志
         return new LoadBalancerCaffeineWarnLogger();
      }

   }

   static class LoadBalancerCaffeineWarnLogger {

      private static final Log LOG = LogFactory.getLog(LoadBalancerCaffeineWarnLogger.class);

      @PostConstruct//jdk注解,用来修饰非静态的void方法,加载顺序 构造器 > Autowired > postConstruct
      void logWarning() {
         if (LOG.isWarnEnabled()) {
            LOG.warn("Spring Cloud LoadBalancer is currently working with the default cache. "
                  + "While 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.");
         }
      }
   }

   @Configuration(proxyBeanMethods = false)//不使用代理
   @ConditionalOnClass({ Caffeine.class, CaffeineCacheManager.class })// 加载这两个bean,Caffeine只有我们引入依赖后才有,不满足则不会创建下面的bean
   protected static class CaffeineLoadBalancerCacheManagerConfiguration {

      @Bean(autowireCandidate = false)
      @ConditionalOnMissingBean //LoadBalancerCacheManager是接口,当其不存在spring Bean工厂时,就会创建这个bean,此处一定会创建
      LoadBalancerCacheManager caffeineLoadBalancerCacheManager(LoadBalancerCacheProperties cacheProperties) {
         // 创建caffeine 缓存管理器
         return new CaffeineBasedLoadBalancerCacheManager(cacheProperties);
      }
   }

   @Configuration(proxyBeanMethods = false)//不使用代理
   @Conditional(OnCaffeineCacheMissingCondition.class)// 满足没有引入caffeine才执行
   @ConditionalOnClass(ConcurrentMapWithTimedEviction.class)// 有ConcurrentMapWithTimedEviction才执行
   protected static class DefaultLoadBalancerCacheManagerConfiguration {

      @Bean(autowireCandidate = false)
      @ConditionalOnMissingBean //LoadBalancerCacheManager是接口,当其不存在spring Bean工厂时,就会创建这个bean,此处一定会创建
      LoadBalancerCacheManager defaultLoadBalancerCacheManager(LoadBalancerCacheProperties cacheProperties) {
         // 创建默认缓存管理器
         return new DefaultLoadBalancerCacheManager(cacheProperties);
      }

   }

   static final class OnCaffeineCacheMissingCondition extends AnyNestedCondition {

      private OnCaffeineCacheMissingCondition() {
         super(ConfigurationPhase.REGISTER_BEAN);
      }

      @ConditionalOnMissingClass("com.github.benmanes.caffeine.cache.Caffeine")
      static class CaffeineClassMissing {

      }
      @ConditionalOnMissingClass("org.springframework.cache.caffeine.CaffeineCacheManager")
      static class CaffeineCacheManagerClassMissing {

      }
   }
}

具体的内容都在注释当中,下面我简单总结一下:

  1. LoadBalancerCacheManagerWarnConfiguration:如果没有引入caffeine,则输出默认日志
  2. CaffeineLoadBalancerCacheManagerConfiguration:加载caffeine配置,生成对应的缓存bean
  3. DefaultLoadBalancerCacheManagerConfiguration:生成默认的缓存bean

注意:这个默认的DefaultLoadBalancerCacheManagerConfiguration不会被加载,因为其前面的条件注解@ConditionalOnClass(ConcurrentMapWithTimedEviction.class)没有满足,缺少这个bean,需要额外增加依赖,所以不会执行。

也就是说:如果不引入caffeine,那么默认的缓存也不生效,相当于没有缓存。

解决方案1:引入caffeine依赖

解决方法

引入caffeine依赖:

<dependency>
    <groupId>com.github.ben-manes.caffeine</groupId>
    <artifactId>caffeine</artifactId>
    <version>2.9.3</version>
</dependency>

 下边这个依赖也必须引入

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
</dependency>

注意

  1. 不要引入过高的版本,建议在3.X以下版本。
    1. 否则会导致引入无效,仍然会抛出警告。
    2. 无效不是CaffeineManager没有加载。当我们引入错误版本的caffeine后会报出版本兼容性的问题。也许你升高jdk的版本可能会解决这个问题,但基于jdk1.8的环境还是建议在3.x之下版本。
    3. 本处我测试结果
      1. 成功的版本:2.8.8、2.9.3
      2. 失败的版本:3.X。
  2. 引入caffeine依赖即生效,无需其他配置。

结果(启动和请求时都没有警告)

D:\dev\Java\jdk1.8.0_201\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:60944,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\Liu\AppData\Local\Temp\captureAgent2529jars\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\dev\Java\jdk1.8.0_201\jre\lib\charsets.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\deploy.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\access-bridge-64.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\cldrdata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\dnsns.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jaccess.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\localedata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\nashorn.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunec.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunjce_provider.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunmscapi.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunpkcs11.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\zipfs.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\javaws.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jce.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfr.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfxswt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jsse.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\management-agent.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\plugin.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\resources.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\rt.jar;E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\account\account-api\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\storage\storage-api\target\classes;E:\work\maven\repository\com\github\ben-manes\caffeine\caffeine\2.9.3\caffeine-2.9.3.jar;E:\work\maven\repository\org\checkerframework\checker-qual\3.19.0\checker-qual-3.19.0.jar;E:\work\maven\repository\com\google\errorprone\error_prone_annotations\2.10.0\error_prone_annotations-2.10.0.jar;E:\work\maven\repository\org\springframework\spring-context-support\5.3.13\spring-context-support-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-beans\5.3.13\spring-beans-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-context\5.3.13\spring-context-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-aop\5.3.13\spring-aop-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-expression\5.3.13\spring-expression-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-core\5.3.13\spring-core-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-jcl\5.3.13\spring-jcl-5.3.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter\2.4.13\spring-boot-starter-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot\2.4.13\spring-boot-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.4.13\spring-boot-autoconfigure-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.4.13\spring-boot-starter-logging-2.4.13.jar;E:\work\maven\repository\ch\qos\logback\logback-classic\1.2.7\logback-classic-1.2.7.jar;E:\work\maven\repository\ch\qos\logback\logback-core\1.2.7\logback-core-1.2.7.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\work\maven\repository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;E:\work\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\work\maven\repository\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;E:\work\maven\repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-config\2021.1\spring-cloud-starter-alibaba-nacos-config-2021.1.jar;E:\work\maven\repository\com\alibaba\spring\spring-context-support\1.0.10\spring-context-support-1.0.10.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-client\1.4.1\nacos-client-1.4.1.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-common\1.4.1\nacos-common-1.4.1.jar;E:\work\maven\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;E:\work\maven\repository\org\apache\httpcomponents\httpasyncclient\4.1.4\httpasyncclient-4.1.4.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore-nio\4.4.14\httpcore-nio-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-api\1.4.1\nacos-api-1.4.1.jar;E:\work\maven\repository\com\google\guava\guava\24.1.1-jre\guava-24.1.1-jre.jar;E:\work\maven\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;E:\work\maven\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;E:\work\maven\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;E:\work\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;E:\work\maven\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;E:\work\maven\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-commons\3.0.1\spring-cloud-commons-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-crypto\5.4.9\spring-security-crypto-5.4.9.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-context\3.0.1\spring-cloud-context-3.0.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2021.1\spring-cloud-starter-alibaba-nacos-discovery-2021.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2021.1\spring-cloud-alibaba-commons-2021.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-loadbalancer\3.0.1\spring-cloud-loadbalancer-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-validation\2.4.13\spring-boot-starter-validation-2.4.13.jar;E:\work\maven\repository\org\glassfish\jakarta.el\3.0.4\jakarta.el-3.0.4.jar;E:\work\maven\repository\org\hibernate\validator\hibernate-validator\6.1.7.Final\hibernate-validator-6.1.7.Final.jar;E:\work\maven\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;E:\work\maven\repository\org\jboss\logging\jboss-logging\3.4.2.Final\jboss-logging-3.4.2.Final.jar;E:\work\maven\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;E:\work\maven\repository\io\projectreactor\reactor-core\3.4.12\reactor-core-3.4.12.jar;E:\work\maven\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\work\maven\repository\io\projectreactor\addons\reactor-extra\3.4.5\reactor-extra-3.4.5.jar;E:\work\Idea_proj\router4j\router4j-example\common\target\classes;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-web\2.4.13\spring-boot-starter-web-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-json\2.4.13\spring-boot-starter-json-2.4.13.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.4.13\spring-boot-starter-tomcat-2.4.13.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.55\tomcat-embed-core-9.0.55.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.55\tomcat-embed-websocket-9.0.55.jar;E:\work\maven\repository\org\springframework\spring-web\5.3.13\spring-web-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-webmvc\5.3.13\spring-webmvc-5.3.13.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter-openfeign\3.0.1\spring-cloud-starter-openfeign-3.0.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter\3.0.1\spring-cloud-starter-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;E:\work\maven\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;E:\work\maven\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-openfeign-core\3.0.1\spring-cloud-openfeign-core-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.4.13\spring-boot-starter-aop-2.4.13.jar;E:\work\maven\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form-spring\3.8.0\feign-form-spring-3.8.0.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form\3.8.0\feign-form-3.8.0.jar;E:\work\maven\repository\commons-fileupload\commons-fileupload\1.4\commons-fileupload-1.4.jar;E:\work\maven\repository\io\github\openfeign\feign-core\10.10.1\feign-core-10.10.1.jar;E:\work\maven\repository\io\github\openfeign\feign-slf4j\10.10.1\feign-slf4j-10.10.1.jar;E:\work\maven\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.3\lib\idea_rt.jar" com.knife.order.OrderApplication
Connected to the target VM, address: '127.0.0.1:60944', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.4.13)

2022-05-04 10:45:24.828  INFO 9396 --- [           main] com.knife.order.OrderApplication         : Starting OrderApplication using Java 1.8.0_201 on DESKTOP-QI6B9ME with PID 9396 (E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes started by Liu in E:\work\Idea_proj\router4j\router4j-example)
2022-05-04 10:45:24.831  INFO 9396 --- [           main] com.knife.order.OrderApplication         : No active profile set, falling back to default profiles: default
2022-05-04 10:45:25.586  INFO 9396 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=52076acf-4125-3fd1-9190-d5470c15b448
2022-05-04 10:45:25.867  INFO 9396 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9012 (http)
2022-05-04 10:45:25.876  INFO 9396 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-05-04 10:45:25.876  INFO 9396 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-05-04 10:45:25.978  INFO 9396 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-05-04 10:45:25.978  INFO 9396 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1101 ms
2022-05-04 10:45:27.900  INFO 9396 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9012 (http) with context path ''
2022-05-04 10:45:27.909  INFO 9396 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP order 192.168.0.102:9012 register finished
2022-05-04 10:45:28.445  INFO 9396 --- [           main] com.knife.order.OrderApplication         : Started OrderApplication in 4.648 seconds (JVM running for 5.621)
2022-05-04 10:47:42.535  INFO 9396 --- [nio-9012-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-05-04 10:47:42.535  INFO 9396 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-05-04 10:47:42.536  INFO 9396 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-05-04 10:47:42.570  INFO 9396 --- [nio-9012-exec-1] c.k.order.controller.OrderController     : 订单服务:创建订单:Order(id=null, userId=1, productId=1, count=10, money=100, status=null, createTime=null, updateTime=null)

解决方案2:使用默认缓存

说明

        我在前面曾提到:默认情况下缺少依赖,导致默认的缓存无法使用。

        虽然日志输出了当前使用的是本地缓存,但经过代码跟踪,发现根本没有使用本地缓存,甚至没有使用缓存。

解决方法

引入evictor依赖

<dependency>
    <groupId>com.stoyanr</groupId>
    <artifactId>evictor</artifactId>
    <version>1.0.0</version>
</dependency>

结果(启动时有警告,调feign时无警告)

D:\dev\Java\jdk1.8.0_201\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:60836,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -javaagent:C:\Users\Liu\AppData\Local\Temp\captureAgent3390jars\debugger-agent.jar -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\dev\Java\jdk1.8.0_201\jre\lib\charsets.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\deploy.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\access-bridge-64.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\cldrdata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\dnsns.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jaccess.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\localedata.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\nashorn.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunec.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunjce_provider.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunmscapi.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\sunpkcs11.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\ext\zipfs.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\javaws.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jce.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfr.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jfxswt.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\jsse.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\management-agent.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\plugin.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\resources.jar;D:\dev\Java\jdk1.8.0_201\jre\lib\rt.jar;E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\account\account-api\target\classes;E:\work\Idea_proj\router4j\router4j-example\business\storage\storage-api\target\classes;E:\work\maven\repository\com\stoyanr\evictor\1.0.0\evictor-1.0.0.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter\2.4.13\spring-boot-starter-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot\2.4.13\spring-boot-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.4.13\spring-boot-autoconfigure-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.4.13\spring-boot-starter-logging-2.4.13.jar;E:\work\maven\repository\ch\qos\logback\logback-classic\1.2.7\logback-classic-1.2.7.jar;E:\work\maven\repository\ch\qos\logback\logback-core\1.2.7\logback-core-1.2.7.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;E:\work\maven\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;E:\work\maven\repository\org\slf4j\jul-to-slf4j\1.7.32\jul-to-slf4j-1.7.32.jar;E:\work\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\work\maven\repository\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;E:\work\maven\repository\org\slf4j\slf4j-api\1.7.32\slf4j-api-1.7.32.jar;E:\work\maven\repository\org\springframework\spring-core\5.3.13\spring-core-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-jcl\5.3.13\spring-jcl-5.3.13.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-config\2021.1\spring-cloud-starter-alibaba-nacos-config-2021.1.jar;E:\work\maven\repository\com\alibaba\spring\spring-context-support\1.0.10\spring-context-support-1.0.10.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-client\1.4.1\nacos-client-1.4.1.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-common\1.4.1\nacos-common-1.4.1.jar;E:\work\maven\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;E:\work\maven\repository\org\apache\httpcomponents\httpasyncclient\4.1.4\httpasyncclient-4.1.4.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpcore-nio\4.4.14\httpcore-nio-4.4.14.jar;E:\work\maven\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;E:\work\maven\repository\com\alibaba\nacos\nacos-api\1.4.1\nacos-api-1.4.1.jar;E:\work\maven\repository\com\google\guava\guava\24.1.1-jre\guava-24.1.1-jre.jar;E:\work\maven\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;E:\work\maven\repository\org\checkerframework\checker-compat-qual\2.0.0\checker-compat-qual-2.0.0.jar;E:\work\maven\repository\com\google\errorprone\error_prone_annotations\2.1.3\error_prone_annotations-2.1.3.jar;E:\work\maven\repository\com\google\j2objc\j2objc-annotations\1.1\j2objc-annotations-1.1.jar;E:\work\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.14\animal-sniffer-annotations-1.14.jar;E:\work\maven\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;E:\work\maven\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-commons\3.0.1\spring-cloud-commons-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-crypto\5.4.9\spring-security-crypto-5.4.9.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-context\3.0.1\spring-cloud-context-3.0.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2021.1\spring-cloud-starter-alibaba-nacos-discovery-2021.1.jar;E:\work\maven\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2021.1\spring-cloud-alibaba-commons-2021.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-loadbalancer\3.0.1\spring-cloud-loadbalancer-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-validation\2.4.13\spring-boot-starter-validation-2.4.13.jar;E:\work\maven\repository\org\glassfish\jakarta.el\3.0.4\jakarta.el-3.0.4.jar;E:\work\maven\repository\org\hibernate\validator\hibernate-validator\6.1.7.Final\hibernate-validator-6.1.7.Final.jar;E:\work\maven\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;E:\work\maven\repository\org\jboss\logging\jboss-logging\3.4.2.Final\jboss-logging-3.4.2.Final.jar;E:\work\maven\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;E:\work\maven\repository\io\projectreactor\reactor-core\3.4.12\reactor-core-3.4.12.jar;E:\work\maven\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\work\maven\repository\io\projectreactor\addons\reactor-extra\3.4.5\reactor-extra-3.4.5.jar;E:\work\Idea_proj\router4j\router4j-example\common\target\classes;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-web\2.4.13\spring-boot-starter-web-2.4.13.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-json\2.4.13\spring-boot-starter-json-2.4.13.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;E:\work\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.4.13\spring-boot-starter-tomcat-2.4.13.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.55\tomcat-embed-core-9.0.55.jar;E:\work\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.55\tomcat-embed-websocket-9.0.55.jar;E:\work\maven\repository\org\springframework\spring-web\5.3.13\spring-web-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-beans\5.3.13\spring-beans-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-webmvc\5.3.13\spring-webmvc-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-aop\5.3.13\spring-aop-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-context\5.3.13\spring-context-5.3.13.jar;E:\work\maven\repository\org\springframework\spring-expression\5.3.13\spring-expression-5.3.13.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter-openfeign\3.0.1\spring-cloud-starter-openfeign-3.0.1.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-starter\3.0.1\spring-cloud-starter-3.0.1.jar;E:\work\maven\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;E:\work\maven\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;E:\work\maven\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;E:\work\maven\repository\org\springframework\cloud\spring-cloud-openfeign-core\3.0.1\spring-cloud-openfeign-core-3.0.1.jar;E:\work\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.4.13\spring-boot-starter-aop-2.4.13.jar;E:\work\maven\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form-spring\3.8.0\feign-form-spring-3.8.0.jar;E:\work\maven\repository\io\github\openfeign\form\feign-form\3.8.0\feign-form-3.8.0.jar;E:\work\maven\repository\commons-fileupload\commons-fileupload\1.4\commons-fileupload-1.4.jar;E:\work\maven\repository\io\github\openfeign\feign-core\10.10.1\feign-core-10.10.1.jar;E:\work\maven\repository\io\github\openfeign\feign-slf4j\10.10.1\feign-slf4j-10.10.1.jar;E:\work\maven\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;D:\Program Files\JetBrains\IntelliJ IDEA 2021.2.3\lib\idea_rt.jar" com.knife.order.OrderApplication
Connected to the target VM, address: '127.0.0.1:60836', transport: 'socket'

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.4.13)

2022-05-04 09:58:42.000  INFO 5896 --- [           main] com.knife.order.OrderApplication         : Starting OrderApplication using Java 1.8.0_201 on DESKTOP-QI6B9ME with PID 5896 (E:\work\Idea_proj\router4j\router4j-example\business\order\order-core\target\classes started by Liu in E:\work\Idea_proj\router4j\router4j-example)
2022-05-04 09:58:42.002  INFO 5896 --- [           main] com.knife.order.OrderApplication         : No active profile set, falling back to default profiles: default
2022-05-04 09:58:42.715  INFO 5896 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=5f129227-59b8-30ac-b007-e14673daeb87
2022-05-04 09:58:42.991  INFO 5896 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9012 (http)
2022-05-04 09:58:43.001  INFO 5896 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-05-04 09:58:43.001  INFO 5896 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.55]
2022-05-04 09:58:43.107  INFO 5896 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-05-04 09:58:43.107  INFO 5896 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1059 ms
2022-05-04 09:58:44.769  WARN 5896 --- [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-05-04 09:58:44.957  INFO 5896 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9012 (http) with context path ''
2022-05-04 09:58:44.966  INFO 5896 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP order 192.168.0.102:9012 register finished
2022-05-04 09:58:45.489  INFO 5896 --- [           main] com.knife.order.OrderApplication         : Started OrderApplication in 4.464 seconds (JVM running for 5.488)
2022-05-04 10:00:34.941  INFO 5896 --- [nio-9012-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-05-04 10:00:34.941  INFO 5896 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-05-04 10:00:34.942  INFO 5896 --- [nio-9012-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2022-05-04 10:00:34.983  INFO 5896 --- [nio-9012-exec-1] c.k.order.controller.OrderController     : 订单服务:创建订单:Order(id=null, userId=1, productId=1, count=10, money=100, status=null, createTime=null, updateTime=null)

其他网址

SpringCloudGateway关于Cache的警告你关注过吗 - 代码天地

升级Spring Cloud Alibaba 2021.1,Spring Cloud 2020.0.1,Spring Boot 2.4.2碰到的一系列兼容性问题及解决方案_tuine的博客-CSDN博客

相关文章

暂无评论

暂无评论...