SpringCloud的eureka启动出现APPLICATION FAILED TO START

本文记录了一次Eureka服务注册中心启动失败的问题排查过程,错误出现在尝试创建名为'traceFilterRegistration'的bean时,缺少了类型为'javax.servlet.Filter'的依赖。解决办法是重新下载并重建项目,同时建议定义缺失的过滤器bean。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:这种错误出现的原因还有其他,比如说你在dao多添加一个注解类似的,少添加注解或者其他的,我这边就是Eureka启动出现得,跟其他没关系,为了就是让更少人翻跟头。

2019-04-27 13:36:00.057  INFO 14544 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@498d318c: startup date [Sat Apr 27 13:36:00 CST 2019]; root of context hierarchy
2019-04-27 13:36:00.394  INFO 14544 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-04-27 13:36:00.435  INFO 14544 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f110fcfe] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

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

2019-04-27 13:36:00.857  INFO 14544 --- [           main] com.st.app.EureKaServer                  : No active profile set, falling back to default profiles: default
2019-04-27 13:36:00.870  INFO 14544 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4fce136b: startup date [Sat Apr 27 13:36:00 CST 2019]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@498d318c
2019-04-27 13:36:01.433  INFO 14544 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-04-27 13:36:01.665  INFO 14544 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=ca0ffc6f-9ce9-3ed6-a0ce-99d8d7ae4b88
2019-04-27 13:36:01.677  INFO 14544 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-04-27 13:36:01.780  INFO 14544 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$f110fcfe] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-04-27 13:36:02.068  INFO 14544 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8761 (http)
2019-04-27 13:36:02.078  INFO 14544 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2019-04-27 13:36:02.079  INFO 14544 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.14
2019-04-27 13:36:02.212  INFO 14544 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-04-27 13:36:02.213  INFO 14544 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1343 ms
2019-04-27 13:36:02.596 ERROR 14544 --- [ost-startStop-1] o.s.b.c.embedded.tomcat.TomcatStarter    : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'traceFilterRegistration' defined in class path resource [org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.class]: Unsatisfied dependency expressed through method 'traceFilterRegistration' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.servlet.Filter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=webRequestLoggingFilter)}
2019-04-27 13:36:02.624  WARN 14544 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
2019-04-27 13:36:02.750 ERROR 14544 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Parameter 0 of method traceFilterRegistration in org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration required a bean of type 'javax.servlet.Filter' that could not be found.


Action:

Consider defining a bean of type 'javax.servlet.Filter' in your configuration.


错误的原因以及解决方案:

具体原因我也不太清楚,我就是给我的仓库全部删除了,然后重新下载一遍就可以了

### 实现和部署Spring Cloud架构下的独立支付服务 #### 1. 环境准备 为了构建基于Spring Cloud的独立支付服务,环境配置至关重要。确保安装了Java开发工具包(JDK),并设置好Maven或Gradle作为构建工具。此外,还需准备好Git以便管理源码版本控制。 #### 2. 创建基础项目 创建一个新的Spring Boot应用程序来充当支付服务的基础模块。可以通过访问[start.spring.io](https://start.spring.io/)网站自动生成初始代码结构,选择必要的依赖项如`spring-boot-starter-web`, `spring-cloud-starter-netflix-eureka-client`等[^2]。 ```java @SpringBootApplication @EnableEurekaClient public class PaymentServiceApplication { public static void main(String[] args) { SpringApplication.run(PaymentServiceApplication.class, args); } } ``` #### 3. 配置服务注册与发现 利用Eureka Server来进行服务间的自动注册和服务发现功能。这使得其他微服务能够轻松找到并调用此支付服务API接口。 ```yaml eureka: client: serviceUrl: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ instance: hostname: localhost port: ${PORT:${SERVER_PORT:8081}} ``` #### 4. 实现微服务逻辑 定义RESTful风格的服务端点处理来自客户端的各种请求操作,例如发起支付、查询订单状态等功能。可以采用Feign Client简化HTTP通信过程中的编码工作量。 ```java @FeignClient(name="PAYMENT-SERVICE", fallback=PaymentFallbackService.class) public interface PaymentService { @PostMapping("/payment/create") CommonResult create(@RequestBody Payment payment); } @RestController @RequestMapping("/api/payment") public class PaymentController { private final PaymentService paymentService; @Autowired public PaymentController(PaymentService paymentService){ this.paymentService = paymentService; } @GetMapping("/{id}") public ResponseEntity<CommonResult> getPaymentById(@PathVariable Long id){ return new ResponseEntity<>(this.paymentService.create(new Payment(id)), HttpStatus.OK); } } ``` #### 5. 熔断与降级机制 引入Hystrix库提供熔断器模式的支持,在遇到异常情况时快速失败而不是长时间等待响应结果;同时设定合理的回退策略以保障用户体验不受影响。 ```java @Component @Slf4j class PaymentFallbackService implements FallbackFactory<PaymentService>{ @Override public PaymentService create(Throwable cause) { log.error("Error occurred while processing request.", cause); return new PaymentService() { @Override public CommonResult create(Payment payment) { return new CommonResult(444,"Payment creation failed or timed out"); } }; } } ``` #### 6. API网关集成 借助Zuul/Zuul2或者更现代的选择Gateway建立统一入口点,负责路由转发至具体的目标微服务实例上执行业务流程,并可附加安全认证等相关中间件组件增强整体安全性。 #### 7. 配置中心支持 通过Spring Cloud Config集中化管理和分发各个子系统的属性文件内容给对应的节点读取使用,便于维护多套不同运行环境下的一致性和灵活性调整参数值而无需重新打包发布新版本软件产品。 #### 8. 分布式追踪系统接入 考虑加入像Zipkin这样的分布式跟踪平台收集链路数据帮助定位性能瓶颈所在位置以及排查跨多个服务之间的交互问题根源所在之处。 #### 9. Docker容器化部署方案 最后一步就是将整个应用打成Docker镜像形式上传到私有仓库中保存起来供后续CI/CD流水线自动化测试验证环节调用直至最终上线正式环境中稳定运行[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值