SpringCloud gateway 项目启动报错
错误信息:
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/ServletEndpointManagementContextConfigurationW e b M v c S e r v l e t E n d p o i n t M a n a g e m e n t C o n t e x t C o n f i g u r a t i o n . c l a s s ] : B e a n i n s t a n t i a t i o n v i a f a c t o r y m e t h o d f a i l e d ; n e s t e d e x c e p t i o n i s o r g . s p r i n g f r a m e w o r k . b e a n s . B e a n I n s t a n t i a t i o n E x c e p t i o n : F a i l e d t o i n s t a n t i a t e [ o r g . s p r i n g f r a m e w o r k . b o o t . a c t u a t e . e n d p o i n t . w e b . S e r v l e t E n d p o i n t R e g i s t r a r ] : F a c t o r y m e t h o d ′ s e r v l e t E n d p o i n t R e g i s t r a r ′ t h r e w e x c e p t i o n ; n e s t e d e x c e p t i o n i s o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . U n s a t i s f i e d D e p e n d e n c y E x c e p t i o n : E r r o r c r e a t i n g b e a n w i t h n a m e ′ g a t e w a y C o n t r o l l e r E n d p o i n t ′ d e f i n e d i n c l a s s p a t h r e s o u r c e [ o r g / s p r i n g f r a m e w o r k / c l o u d / g a t e w a y / c o n f i g / G a t e w a y A u t o C o n f i g u r a t i o n 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/GatewayAutoConfigurationWebMvcServletEndpointManagementContextConfiguration.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]:Factorymethod′servletEndpointRegistrar′threwexception;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′gatewayControllerEndpoint′definedinclasspathresource[org/springframework/cloud/gateway/config/GatewayAutoConfigurationGatewayActuatorConfiguration.class]: Unsatisfied dependency expressed through method ‘gatewayControllerEndpoint’ parameter 2; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘weightCalculatorWebFilter’ defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘weightCalculatorWebFilter’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘gatewayConfigurationService’ defined in class path resource [org/springframework/cloud/gateway/config/GatewayAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘gatewayConfigurationService’ parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.springframework.core.convert.ConversionService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webFluxConversionService)}
2020-07-21 21:39:19.599 INFO 2184 — [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
错误原因:
在pom.xml中添加了spring-cloud-starter-gateway,该jar包已经包含了spring-boot-starter-web,不需要再额外添加,不然就会出现上述错误。