项目场景:

使用springcloud的gteway进行网关配置

 


问题描述

gateway启动失败

完整报错:

"C:\Program Files\Java\jdk-11\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\IntelliJIdeaProfessional\IntelliJ IDEA 2021.3.3\lib\idea_rt.jar=53134:D:\IntelliJIdeaProfessional\IntelliJ IDEA 2021.3.3\bin" -Dfile.encoding=UTF-8 -classpath D:\itcast\cloud-demo\gateway\target\classes;C:\Users\HONOR\.m2\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;C:\Users\HONOR\.m2\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2.2.5.RELEASE\spring-cloud-alibaba-commons-2.2.5.RELEASE.jar;C:\Users\HONOR\.m2\repository\com\alibaba\nacos\nacos-client\1.4.1\nacos-client-1.4.1.jar;C:\Users\HONOR\.m2\repository\com\alibaba\nacos\nacos-common\1.4.1\nacos-common-1.4.1.jar;C:\Users\HONOR\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\HONOR\.m2\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;C:\Users\HONOR\.m2\repository\org\apache\httpcomponents\httpasyncclient\4.1.4\httpasyncclient-4.1.4.jar;C:\Users\HONOR\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;C:\Users\HONOR\.m2\repository\org\apache\httpcomponents\httpcore-nio\4.4.13\httpcore-nio-4.4.13.jar;C:\Users\HONOR\.m2\repository\com\alibaba\nacos\nacos-api\1.4.1\nacos-api-1.4.1.jar;C:\Users\HONOR\.m2\repository\com\google\guava\guava\30.0-jre\guava-30.0-jre.jar;C:\Users\HONOR\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\HONOR\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\HONOR\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\HONOR\.m2\repository\org\checkerframework\checker-qual\3.5.0\checker-qual-3.5.0.jar;C:\Users\HONOR\.m2\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;C:\Users\HONOR\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\HONOR\.m2\repository\commons-codec\commons-codec\1.14\commons-codec-1.14.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.11.2\jackson-core-2.11.2.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.11.2\jackson-databind-2.11.2.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.2\jackson-annotations-2.11.2.jar;C:\Users\HONOR\.m2\repository\io\prometheus\simpleclient\0.5.0\simpleclient-0.5.0.jar;C:\Users\HONOR\.m2\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;C:\Users\HONOR\.m2\repository\com\alibaba\spring\spring-context-support\1.0.10\spring-context-support-1.0.10.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-commons\2.2.9.RELEASE\spring-cloud-commons-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\security\spring-security-crypto\5.3.4.RELEASE\spring-security-crypto-5.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-context\2.2.9.RELEASE\spring-cloud-context-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.2.9.RELEASE\spring-cloud-starter-netflix-ribbon-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-netflix-ribbon\2.2.9.RELEASE\spring-cloud-netflix-ribbon-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-netflix-archaius\2.2.9.RELEASE\spring-cloud-netflix-archaius-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.2.9.RELEASE\spring-cloud-starter-netflix-archaius-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\com\netflix\archaius\archaius-core\0.7.7\archaius-core-0.7.7.jar;C:\Users\HONOR\.m2\repository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;C:\Users\HONOR\.m2\repository\com\netflix\ribbon\ribbon\2.3.0\ribbon-2.3.0.jar;C:\Users\HONOR\.m2\repository\com\netflix\ribbon\ribbon-transport\2.3.0\ribbon-transport-2.3.0.jar;C:\Users\HONOR\.m2\repository\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;C:\Users\HONOR\.m2\repository\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;C:\Users\HONOR\.m2\repository\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;C:\Users\HONOR\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\HONOR\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\HONOR\.m2\repository\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;C:\Users\HONOR\.m2\repository\com\netflix\ribbon\ribbon-core\2.3.0\ribbon-core-2.3.0.jar;C:\Users\HONOR\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\HONOR\.m2\repository\com\netflix\ribbon\ribbon-httpclient\2.3.0\ribbon-httpclient-2.3.0.jar;C:\Users\HONOR\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\HONOR\.m2\repository\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar;C:\Users\HONOR\.m2\repository\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;C:\Users\HONOR\.m2\repository\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;C:\Users\HONOR\.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;C:\Users\HONOR\.m2\repository\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;C:\Users\HONOR\.m2\repository\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;C:\Users\HONOR\.m2\repository\com\netflix\netflix-commons\netflix-commons-util\0.3.0\netflix-commons-util-0.3.0.jar;C:\Users\HONOR\.m2\repository\com\netflix\ribbon\ribbon-loadbalancer\2.3.0\ribbon-loadbalancer-2.3.0.jar;C:\Users\HONOR\.m2\repository\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;C:\Users\HONOR\.m2\repository\io\reactivex\rxjava\1.3.8\rxjava-1.3.8.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-starter-gateway\2.2.9.RELEASE\spring-cloud-starter-gateway-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-starter\2.2.9.RELEASE\spring-cloud-starter-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter\2.3.4.RELEASE\spring-boot-starter-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot\2.3.4.RELEASE\spring-boot-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-context\5.2.9.RELEASE\spring-context-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-aop\5.2.9.RELEASE\spring-aop-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-expression\5.2.9.RELEASE\spring-expression-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.4.RELEASE\spring-boot-autoconfigure-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.3.4.RELEASE\spring-boot-starter-logging-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\HONOR\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\HONOR\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;C:\Users\HONOR\.m2\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;C:\Users\HONOR\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\HONOR\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-core\5.2.9.RELEASE\spring-core-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-jcl\5.2.9.RELEASE\spring-jcl-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;C:\Users\HONOR\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;C:\Users\HONOR\.m2\repository\org\springframework\cloud\spring-cloud-gateway-server\2.2.9.RELEASE\spring-cloud-gateway-server-2.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter-validation\2.3.4.RELEASE\spring-boot-starter-validation-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;C:\Users\HONOR\.m2\repository\org\hibernate\validator\hibernate-validator\6.1.5.Final\hibernate-validator-6.1.5.Final.jar;C:\Users\HONOR\.m2\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\Users\HONOR\.m2\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\Users\HONOR\.m2\repository\io\projectreactor\addons\reactor-extra\3.3.4.RELEASE\reactor-extra-3.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\io\projectreactor\reactor-core\3.3.10.RELEASE\reactor-core-3.3.10.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter-webflux\2.3.4.RELEASE\spring-boot-starter-webflux-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.3.4.RELEASE\spring-boot-starter-json-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.2\jackson-datatype-jdk8-2.11.2.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.2\jackson-datatype-jsr310-2.11.2.jar;C:\Users\HONOR\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.2\jackson-module-parameter-names-2.11.2.jar;C:\Users\HONOR\.m2\repository\org\springframework\boot\spring-boot-starter-reactor-netty\2.3.4.RELEASE\spring-boot-starter-reactor-netty-2.3.4.RELEASE.jar;C:\Users\HONOR\.m2\repository\io\projectreactor\netty\reactor-netty\0.9.12.RELEASE\reactor-netty-0.9.12.RELEASE.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-codec-http\4.1.52.Final\netty-codec-http-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-common\4.1.52.Final\netty-common-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-buffer\4.1.52.Final\netty-buffer-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-transport\4.1.52.Final\netty-transport-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-codec\4.1.52.Final\netty-codec-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-codec-http2\4.1.52.Final\netty-codec-http2-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-handler\4.1.52.Final\netty-handler-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-resolver\4.1.52.Final\netty-resolver-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-handler-proxy\4.1.52.Final\netty-handler-proxy-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-codec-socks\4.1.52.Final\netty-codec-socks-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-transport-native-epoll\4.1.52.Final\netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar;C:\Users\HONOR\.m2\repository\io\netty\netty-transport-native-unix-common\4.1.52.Final\netty-transport-native-unix-common-4.1.52.Final.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-web\5.2.9.RELEASE\spring-web-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-beans\5.2.9.RELEASE\spring-beans-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\springframework\spring-webflux\5.2.9.RELEASE\spring-webflux-5.2.9.RELEASE.jar;C:\Users\HONOR\.m2\repository\org\synchronoss\cloud\nio-multipart-parser\1.1.0\nio-multipart-parser-1.1.0.jar;C:\Users\HONOR\.m2\repository\org\synchronoss\cloud\nio-stream-storage\1.1.3\nio-stream-storage-1.1.3.jar;C:\Users\HONOR\.m2\repository\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar cn.itcast.gateway.GatewayApplication

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

2023-04-09 10:35:42.289  INFO 14728 --- [           main] cn.itcast.gateway.GatewayApplication     : No active profile set, falling back to default profiles: default
2023-04-09 10:35:42.785  INFO 14728 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=f8de00e7-3996-3e2d-bee9-fbe46dd649a0
2023-04-09 10:35:42.800  INFO 14728 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-04-09 10:35:42.802  INFO 14728 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactiveLoadBalancerConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactiveLoadBalancerConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-04-09 10:35:42.805  INFO 14728 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'deferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-04-09 10:35:42.885  WARN 14728 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2023-04-09 10:35:42.886  INFO 14728 --- [           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.
2023-04-09 10:35:42.888  WARN 14728 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2023-04-09 10:35:42.888  INFO 14728 --- [           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.
2023-04-09 10:35:44.175  WARN 14728 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gatewayHttpClient' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration$NettyConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [reactor.netty.http.client.HttpClient]: Factory method 'gatewayHttpClient' threw exception; nested exception is java.lang.NoSuchMethodError: reactor.netty.resources.ConnectionProvider$Builder.evictInBackground(Ljava/time/Duration;)Lreactor/netty/resources/ConnectionProvider$ConnectionPoolSpec;
2023-04-09 10:35:44.192  INFO 14728 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-04-09 10:35:44.196 ERROR 14728 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.gateway.config.GatewayAutoConfiguration$NettyConfiguration.buildConnectionProvider(GatewayAutoConfiguration.java:798)

The following method did not exist:

    reactor.netty.resources.ConnectionProvider$Builder.evictInBackground(Ljava/time/Duration;)Lreactor/netty/resources/ConnectionProvider$ConnectionPoolSpec;

The method's class, reactor.netty.resources.ConnectionProvider$Builder, is available from the following locations:

    jar:file:/C:/Users/HONOR/.m2/repository/io/projectreactor/netty/reactor-netty/0.9.12.RELEASE/reactor-netty-0.9.12.RELEASE.jar!/reactor/netty/resources/ConnectionProvider$Builder.class

The class hierarchy was loaded from the following locations:

    reactor.netty.resources.ConnectionProvider.Builder: file:/C:/Users/HONOR/.m2/repository/io/projectreactor/netty/reactor-netty/0.9.12.RELEASE/reactor-netty-0.9.12.RELEASE.jar
    reactor.netty.resources.ConnectionProvider.ConnectionPoolSpec: file:/C:/Users/HONOR/.m2/repository/io/projectreactor/netty/reactor-netty/0.9.12.RELEASE/reactor-netty-0.9.12.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of reactor.netty.resources.ConnectionProvider$Builder


进程已结束,退出代码1


原因分析:

这里并不是所谓的netty错误,而是因为springboot版本和springcloud不搭。我之前用的是2.3.4的springboot和Hoxton.SR12的springcloud,一直好好的没报错,直到今天使用gateway,一直报错


解决方案:

这是官方提供的版本对应:

如果是Hoxton.SR10,应该对应2.3.8.RELEASE

 

换成严格匹配的版本后,启动成功:

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐