Spring Cloud Gateway报sun.misc.Unsafe.park(Native Method)

项目引入spring cloud gateway的jar报,启动的时候报:

bash 复制代码
[2024-07-05 10:10:16.162][main][ERROR][org.springframework.boot.web.embedded.tomcat.TomcatStarter][61]:Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gatewayControllerEndpoint' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration$GatewayActuatorConfiguration.class]: Unsatisfied dependency expressed through method 'gatewayControllerEndpoint' parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'modifyRequestBodyGatewayFilterFactory' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method 'modifyRequestBodyGatewayFilterFactory' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.http.codec.ServerCodecConfigurer' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
[2024-07-05 10:10:16.188][main][INFO][org.apache.juli.logging.DirectJDKLog][173]:Stopping service [Tomcat]
[2024-07-05 10:10:16.193][main][WARN][org.apache.juli.logging.DirectJDKLog][173]:The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
 java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)
[2024-07-05 10:10:16.196][main][WARN][org.springframework.context.support.AbstractApplicationContext][557]:Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
[2024-07-05 10:10:16.213][main][INFO][org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener][136]:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2024-07-05 10:10:16.434][main][ERROR][org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter][40]:

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

Description:

Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.

解决方案:

网关异常报Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration,

是因为项目引入了spring-boot-starter-web,因为会与spring cloud gateway的webflux冲突。所以项目不要引入spring-boot-starter-web。

本案例是删除spring-boot-starter-web的引入

相关推荐
攸攸太上16 小时前
Spring Gateway学习
java·后端·学习·spring·微服务·gateway
Bulut09073 天前
SpringCloud 2023 Gateway的Predicate配置详解、自定义Route Predicate Factory
spring cloud·gateway·predicate配置详解·自定义路由断言factory·内置路由predicate
努力--坚持3 天前
SpringCloud入门(四)Ribbon负载均衡
负载均衡·springcloud
Cikiss3 天前
微服务实战——ElasticSearch(搜索)
java·分布式·后端·微服务·springcloud
wangqiaowq5 天前
Egress Gateway 是一个重要的组件,用于管理从服务网格内部到外部服务的流量
网络·gateway
wangqiaowq5 天前
Ingress Gateway 它负责处理进入集群的 HTTP 和 TCP 流量
tcp/ip·http·gateway
鲨鱼辣椒ぅ6 天前
springboot集成nacos+gateway+feign
spring boot·后端·gateway
fanhaifeng666 天前
SpringCloud Gateway 打印请求响应日志、跨域全局配置
spring·spring cloud·gateway
大灰狼19138 天前
【基于spring-cloud-gateway实现自己的网关过滤器】
spring cloud·gateway
wangqiaowq9 天前
Gateway和VirtualService
gateway