Consider defining a bean of type ‘org.springframework.http.codec.ServerCodecConfigurer‘ in your conf
背景在使用springcloudgateway启动过程中报错如下:._______ _ _/\\ / ___'_ __ _ _(_)_ ____ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/___)| |_)| | | | | || (_| |) ) ) )'|____| .__|_| |_|_| |_\__, | / / / /===
·
背景
在使用springcloud gateway启动过程中报错如下:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.12.RELEASE)
2021-04-26 10:21:35.671 INFO 11540 --- [ main] c.aimsphm.cloud.CloudGatewayApplication : The following profiles are active: dev
2021-04-26 10:21:36.542 INFO 11540 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=a66473af-951b-3db6-9f82-a54be3b0c8a8
2021-04-26 10:21:36.659 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$a670aa5d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.669 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.673 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@7e446d92' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.678 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$cb454d0f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.682 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration' of type [org.springframework.security.config.annotation.method.configuration.Jsr250MetadataSourceConfiguration$$EnhancerBySpringCGLIB$$f09a6525] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.685 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'jsr250MethodSecurityMetadataSource' of type [org.springframework.security.access.annotation.Jsr250MethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.686 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.699 INFO 11540 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$29dce520] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-04-26 10:21:36.994 INFO 11540 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 10086 (http)
2021-04-26 10:21:37.018 INFO 11540 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-04-26 10:21:37.018 INFO 11540 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.30]
2021-04-26 10:21:37.149 INFO 11540 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-04-26 10:21:37.150 INFO 11540 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1466 ms
2021-04-26 10:21:37.510 INFO 11540 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@34451ed8, org.springframework.security.web.context.SecurityContextPersistenceFilter@14168e1, org.springframework.security.web.header.HeaderWriterFilter@70029d2d, org.springframework.security.web.authentication.logout.LogoutFilter@4d157493, org.springframework.security.web.authentication.logout.LogoutFilter@71179b6f, org.springframework.security.cas.web.CasAuthenticationFilter@23da79eb, org.jasig.cas.client.session.SingleSignOutFilter@16a2ed51, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@6ecc02bb, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1e225820, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6003ad65, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@c1050f2, org.springframework.security.web.session.SessionManagementFilter@709f0202, org.springframework.security.web.access.ExceptionTranslationFilter@1e3ff233, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@3cdc7b09]
2021-04-26 10:21:37.529 WARN 11540 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-04-26 10:21:37.529 INFO 11540 --- [ 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.
2021-04-26 10:21:37.534 WARN 11540 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-04-26 10:21:37.534 INFO 11540 --- [ 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.
2021-04-26 10:21:38.982 WARN 11540 --- [ main] GatewayClassPathWarningAutoConfiguration :
**********************************************************
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway at this time. Please remove spring-boot-starter-web dependency.
**********************************************************
2021-04-26 10:21:41.034 WARN 11540 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routeDefinitionRouteLocator' defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method 'routeDefinitionRouteLocator' parameter 1; 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: {}
2021-04-26 10:21:41.038 INFO 11540 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-04-26 10:21:41.050 INFO 11540 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-04-26 10:21:41.176 ERROR 11540 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.
看到错误实际上是有点懵的,但是智能的spring早已经告诉你可能需要的修改方式
这是因为我的根pom引用spring-boot-starter-web导致的,需要取消掉。因为Spring Cloud Gateway 是使用 netty+webflux实现,webflux与web是冲突的。
更多推荐
已为社区贡献2条内容
所有评论(0)