zoukankan      html  css  js  c++  java
  • Spring boot启动报“APPLICATION FAILED TO START”错误:DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found

    Spring boot启动报“APPLICATION FAILED TO START”错误:DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found

    具体报错日志如下:

    2020-04-21 00:10:16.397 ERROR 25829 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  {cyan} : 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 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'diskSpaceHealthIndicator' defined in class path resource [org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'diskSpaceHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties' available: expected single matching bean but found 2: diskSpaceHealthIndicatorProperties,management.health.diskspace-org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties
    2020-04-21 00:10:16.495 ERROR 25829 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   {cyan} : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Parameter 0 of method diskSpaceHealthIndicator in org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found:
        - diskSpaceHealthIndicatorProperties: defined by method 'diskSpaceHealthIndicatorProperties' in class path resource [org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.class]
        - management.health.diskspace-org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties: defined in null
    
    
    Action:
    
    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
    
    2020-04-21 00:10:16.496 ERROR 25829 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   {cyan} : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Parameter 0 of method diskSpaceHealthIndicator in org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found:
        - diskSpaceHealthIndicatorProperties: defined by method 'diskSpaceHealthIndicatorProperties' in class path resource [org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.class]
        - management.health.diskspace-org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties: defined in null
    
    
    Action:
    
    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
    
    2020-04-21 00:10:16.496 ERROR 25829 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   {cyan} : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Parameter 0 of method diskSpaceHealthIndicator in org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found:
        - diskSpaceHealthIndicatorProperties: defined by method 'diskSpaceHealthIndicatorProperties' in class path resource [org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.class]
        - management.health.diskspace-org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties: defined in null
    
    
    Action:
    
    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
    
    2020-04-21 00:10:16.497 ERROR 25829 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   {cyan} : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Parameter 0 of method diskSpaceHealthIndicator in org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorAutoConfiguration required a single bean, but 2 were found:
        - diskSpaceHealthIndicatorProperties: defined by method 'diskSpaceHealthIndicatorProperties' in class path resource [org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.class]
        - management.health.diskspace-org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthIndicatorProperties: defined in null
    
    
    Action:
    
    Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed

    问题分析:

    网上找不到类似的问题,困扰了我两三天,最初发现和打包方式有关系,打成可执行包是没问题,打成lib依赖包分离的方式就有问题。

    后来进一步分析,发现是因为我近期升级了spring boot的版本,旧的版本依赖包在lib里没有没有清除干净,删掉全部依赖包后,重新生成就可以了。

    ^^ 分享一下,说不定谁又遇到类似的问题。

  • 相关阅读:
    制作centos镜像,启动镜像可以访问本地百度页面
    docker配置镜像加速后报错 系统 CentOS7
    代理方式获取天气预报信息
    周边分析-距离计算
    mysql随笔
    mysql笔记
    树形结构表的存储【转自:http://www.cnblogs.com/huangfox/archive/2012/04/11/2442408.html】
    Mysql中 in 和 exists 区别
    CPU飙高,系统性能问题如何排查?
    位运算的常见操作
  • 原文地址:https://www.cnblogs.com/zhaohz/p/12763471.html
Copyright © 2011-2022 走看看