Error creating bean with name ‘ribbonLoadBalancer‘ defined in org.springframework.cloud.netflix.ribb

目录

  • 报错内容
  • 解决方案

报错内容

 D:\jdk1.8\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:D:\IDEA\IntelliJ IDEA 2021.1\lib\idea_rt.jar=49367:D:\IDEA\IntelliJ IDEA 2021.1\bin" -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath "D:\jdk1.8\jre\lib\charsets.jar;D:\jdk1.8\jre\lib\deploy.jar;D:\jdk1.8\jre\lib\ext\access-bridge-64.jar;D:\jdk1.8\jre\lib\ext\cldrdata.jar;D:\jdk1.8\jre\lib\ext\dnsns.jar;D:\jdk1.8\jre\lib\ext\jaccess.jar;D:\jdk1.8\jre\lib\ext\jfxrt.jar;D:\jdk1.8\jre\lib\ext\localedata.jar;D:\jdk1.8\jre\lib\ext\nashorn.jar;D:\jdk1.8\jre\lib\ext\sunec.jar;D:\jdk1.8\jre\lib\ext\sunjce_provider.jar;D:\jdk1.8\jre\lib\ext\sunmscapi.jar;D:\jdk1.8\jre\lib\ext\sunpkcs11.jar;D:\jdk1.8\jre\lib\ext\zipfs.jar;D:\jdk1.8\jre\lib\javaws.jar;D:\jdk1.8\jre\lib\jce.jar;D:\jdk1.8\jre\lib\jfr.jar;D:\jdk1.8\jre\lib\jfxswt.jar;D:\jdk1.8\jre\lib\jsse.jar;D:\jdk1.8\jre\lib\management-agent.jar;D:\jdk1.8\jre\lib\plugin.jar;D:\jdk1.8\jre\lib\resources.jar;D:\jdk1.8\jre\lib\rt.jar;E:\Spring Cloud\day01-SpringCloud01\cloud-demo\order-service\target\classes;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2.2.5.RELEASE\spring-cloud-starter-alibaba-nacos-discovery-2.2.5.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2.2.5.RELEASE\spring-cloud-alibaba-commons-2.2.5.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\nacos\nacos-client\1.4.1\nacos-client-1.4.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\nacos\nacos-common\1.4.1\nacos-common-1.4.1.jar;D:\IDEA\apache-maven-3.8.1\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\httpcomponents\httpasyncclient\4.1.4\httpasyncclient-4.1.4.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\httpcomponents\httpcore-nio\4.4.14\httpcore-nio-4.4.14.jar;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\nacos\nacos-api\1.4.1\nacos-api-1.4.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\guava\guava\29.0-jre\guava-29.0-jre.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;D:\IDEA\apache-maven-3.8.1\repository\org\checkerframework\checker-qual\2.11.1\checker-qual-2.11.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;D:\IDEA\apache-maven-3.8.1\repository\commons-codec\commons-codec\1.14\commons-codec-1.14.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;D:\IDEA\apache-maven-3.8.1\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;D:\IDEA\apache-maven-3.8.1\repository\com\alibaba\spring\spring-context-support\1.0.10\spring-context-support-1.0.10.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-commons\2.2.7.RELEASE\spring-cloud-commons-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\security\spring-security-crypto\5.3.8.RELEASE\spring-security-crypto-5.3.8.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-context\2.2.7.RELEASE\spring-cloud-context-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.2.9.RELEASE\spring-cloud-starter-netflix-ribbon-2.2.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-starter\2.2.7.RELEASE\spring-cloud-starter-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;D:\IDEA\apache-maven-3.8.1\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-netflix-ribbon\2.2.7.RELEASE\spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-netflix-archaius\2.2.7.RELEASE\spring-cloud-netflix-archaius-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.2.7.RELEASE\spring-cloud-starter-netflix-archaius-2.2.7.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\archaius\archaius-core\0.7.7\archaius-core-0.7.7.jar;D:\IDEA\apache-maven-3.8.1\repository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\ribbon\ribbon\2.3.0\ribbon-2.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\ribbon\ribbon-transport\2.3.0\ribbon-transport-2.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\IDEA\apache-maven-3.8.1\repository\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;D:\IDEA\apache-maven-3.8.1\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;D:\IDEA\apache-maven-3.8.1\repository\javax\inject\javax.inject\1\javax.inject-1.jar;D:\IDEA\apache-maven-3.8.1\repository\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\ribbon\ribbon-core\2.3.0\ribbon-core-2.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\IDEA\apache-maven-3.8.1\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\ribbon\ribbon-httpclient\2.3.0\ribbon-httpclient-2.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;D:\IDEA\apache-maven-3.8.1\repository\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\IDEA\apache-maven-3.8.1\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\netflix-commons\netflix-commons-util\0.3.0\netflix-commons-util-0.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\ribbon\ribbon-loadbalancer\2.3.0\ribbon-loadbalancer-2.3.0.jar;D:\IDEA\apache-maven-3.8.1\repository\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\IDEA\apache-maven-3.8.1\repository\io\reactivex\rxjava\1.3.8\rxjava-1.3.8.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter-web\2.3.9.RELEASE\spring-boot-starter-web-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter\2.3.9.RELEASE\spring-boot-starter-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot\2.3.9.RELEASE\spring-boot-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.9.RELEASE\spring-boot-autoconfigure-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter-logging\2.3.9.RELEASE\spring-boot-starter-logging-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\IDEA\apache-maven-3.8.1\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\IDEA\apache-maven-3.8.1\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\IDEA\apache-maven-3.8.1\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-core\5.2.13.RELEASE\spring-core-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-jcl\5.2.13.RELEASE\spring-jcl-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter-json\2.3.9.RELEASE\spring-boot-starter-json-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter-tomcat\2.3.9.RELEASE\spring-boot-starter-tomcat-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.43\tomcat-embed-core-9.0.43.jar;D:\IDEA\apache-maven-3.8.1\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;D:\IDEA\apache-maven-3.8.1\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.43\tomcat-embed-websocket-9.0.43.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-web\5.2.13.RELEASE\spring-web-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-beans\5.2.13.RELEASE\spring-beans-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-webmvc\5.2.13.RELEASE\spring-webmvc-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-aop\5.2.13.RELEASE\spring-aop-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-context\5.2.13.RELEASE\spring-context-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-expression\5.2.13.RELEASE\spring-expression-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\mysql\mysql-connector-java\8.0.26\mysql-connector-java-8.0.26.jar;D:\IDEA\apache-maven-3.8.1\repository\com\google\protobuf\protobuf-java\3.13.0\protobuf-java-3.13.0.jar;D:\IDEA\apache-maven-3.8.1\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.2.0\mybatis-spring-boot-starter-2.2.0.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\boot\spring-boot-starter-jdbc\2.3.9.RELEASE\spring-boot-starter-jdbc-2.3.9.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-jdbc\5.2.13.RELEASE\spring-jdbc-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\springframework\spring-tx\5.2.13.RELEASE\spring-tx-5.2.13.RELEASE.jar;D:\IDEA\apache-maven-3.8.1\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.2.0\mybatis-spring-boot-autoconfigure-2.2.0.jar;D:\IDEA\apache-maven-3.8.1\repository\org\mybatis\mybatis\3.5.7\mybatis-3.5.7.jar;D:\IDEA\apache-maven-3.8.1\repository\org\mybatis\mybatis-spring\2.0.6\mybatis-spring-2.0.6.jar;D:\IDEA\apache-maven-3.8.1\repository\org\projectlombok\lombok\1.18.18\lombok-1.18.18.jar" cn.itcast.order.OrderApplication

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

10-25 18:06:10:848  INFO 1708 --- [           main] cn.itcast.order.OrderApplication         : No active profile set, falling back to default profiles: default
10-25 18:06:11:636  INFO 1708 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=1e3d3419-6ac5-3b72-b649-6b2133cfab3e
10-25 18:06:12:075  INFO 1708 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
10-25 18:06:12:095  INFO 1708 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
10-25 18:06:12:095  INFO 1708 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.43]
10-25 18:06:12:453  INFO 1708 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
10-25 18:06:12:453  INFO 1708 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1579 ms
10-25 18:06:12:794  WARN 1708 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
10-25 18:06:12:795  INFO 1708 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
10-25 18:06:12:798  WARN 1708 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
10-25 18:06:12:798  INFO 1708 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
10-25 18:06:12:957  INFO 1708 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
10-25 18:06:14:779  INFO 1708 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
10-25 18:06:14:795  INFO 1708 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
10-25 18:06:16:539  INFO 1708 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
10-25 18:06:17:381  INFO 1708 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
10-25 18:06:17:425  INFO 1708 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP orderservice 192.168.198.5:8080 register finished
10-25 18:06:19:050  INFO 1708 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
10-25 18:06:19:077  INFO 1708 --- [           main] cn.itcast.order.OrderApplication         : Started OrderApplication in 12.737 seconds (JVM running for 16.387)
10-25 18:06:20:928  WARN 1708 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonLoadBalancingHttpClient' defined in org.springframework.cloud.netflix.ribbon.apache.HttpClientRibbonConfiguration: Unsatisfied dependency expressed through method 'ribbonLoadBalancingHttpClient' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonLoadBalancer' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Unsatisfied dependency expressed through method 'ribbonLoadBalancer' parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ribbonRule' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.IRule]: Factory method 'ribbonRule' threw exception; nested exception is java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
10-25 18:06:21:009 ERROR 1708 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonLoadBalancingHttpClient' defined in org.springframework.cloud.netflix.ribbon.apache.HttpClientRibbonConfiguration: Unsatisfied dependency expressed through method 'ribbonLoadBalancingHttpClient' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonLoadBalancer' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Unsatisfied dependency expressed through method 'ribbonLoadBalancer' parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ribbonRule' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.IRule]: Factory method 'ribbonRule' threw exception; nested exception is java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:799) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:540) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.cloud.context.named.NamedContextFactory.createContext(NamedContextFactory.java:137) ~[spring-cloud-context-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.context.named.NamedContextFactory.getContext(NamedContextFactory.java:102) ~[spring-cloud-context-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.netflix.ribbon.SpringClientFactory.getContext(SpringClientFactory.java:131) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.initialize(RibbonApplicationContextInitializer.java:47) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.onApplicationEvent(RibbonApplicationContextInitializer.java:54) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.onApplicationEvent(RibbonApplicationContextInitializer.java:30) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:108) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:77) ~[spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.9.RELEASE.jar:2.3.9.RELEASE]
	at cn.itcast.order.OrderApplication.main(OrderApplication.java:17) [classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ribbonLoadBalancer' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Unsatisfied dependency expressed through method 'ribbonLoadBalancer' parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ribbonRule' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.IRule]: Factory method 'ribbonRule' threw exception; nested exception is java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:799) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:540) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:886) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:790) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	... 29 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ribbonRule' defined in org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.IRule]: Factory method 'ribbonRule' threw exception; nested exception is java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:637) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:886) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:790) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	... 43 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.IRule]: Factory method 'ribbonRule' threw exception; nested exception is java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:652) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	... 57 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unknown class to load com.netflix.loadbalancer.RandomRuLe for class interface com.netflix.loadbalancer.IRule named userservice
	at org.springframework.cloud.netflix.ribbon.PropertiesFactory.get(PropertiesFactory.java:77) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at org.springframework.cloud.netflix.ribbon.RibbonClientConfiguration.ribbonRule(RibbonClientConfiguration.java:113) ~[spring-cloud-netflix-ribbon-2.2.7.RELEASE.jar:2.2.7.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_281]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_281]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_281]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_281]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.13.RELEASE.jar:5.2.13.RELEASE]
	... 58 common frames omitted

10-25 18:06:21:490  INFO 1708 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
10-25 18:06:21:516  INFO 1708 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'Nacos-Watch-Task-Scheduler'
10-25 18:06:21:519  INFO 1708 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : De-registering from Nacos Server now...
10-25 18:06:21:551  INFO 1708 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : De-registration finished.
10-25 18:06:29:403  WARN 1708 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Destroy method 'close' on bean with name 'nacosServiceRegistry' threw an exception: java.lang.NullPointerException
10-25 18:06:29:403  INFO 1708 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
10-25 18:06:29:458  WARN 1708 --- [      Thread-32] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
10-25 18:06:29:459  WARN 1708 --- [      Thread-32] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end
10-25 18:06:29:458  WARN 1708 --- [      Thread-26] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
10-25 18:06:29:460  WARN 1708 --- [      Thread-26] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Destruction of the end

Process finished with exit code 1

解决方案

  • 如果使用的是Eureka需要引入ribbon依赖
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
            <version>2.2.9.RELEASE</version>
        </dependency>
  • 如果使用的是Nacos,引入了spring-cloud-starter-alibaba-nacos-discovery,则不再需要引入ribbon,其包含了ribbon。

如果你在nacos项目中使用了LoadBalancer,需要引入如下依赖。如果没有则不需要。

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

你可能感兴趣的:(报错,java,spring,cloud)