【问题标题】:Spring Boot Actuator: Failed to bind properties underSpring Boot Actuator:绑定属性失败
【发布时间】:2021-05-05 08:27:14
【问题描述】:

我尝试启用 Spring Boot Actuator(连同 Swagger)并在 pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.4.5</version>
    </dependency>

yml 文件中使用以下config

springdoc:
  api-docs:
    enabled: true
  show:
    actuator: true  


management:
  endpoints:
    web:
      exposure:
        include= "*"
      expose: "*"

当我启动它时,我得到以下异常:

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

Description:

Failed to bind properties under 'management.endpoints.web.exposure' to org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties$Exposure:

    Reason: No converter found capable of converting from type [java.lang.String] to type [org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties$Exposure]

Action:

Update your application's configuration

如何解决这个异常?

【问题讨论】:

  • 在我看来你的 yaml 定义不正确,include= "*" 应该是include: "*"。编辑:参考第一个答案,因此为什么它被解析为字符串值并且 Spring Boot Actuator 无法正确映射

标签: spring-boot spring-boot-actuator


【解决方案1】:

你的 YAML 有一个 = 而不是 :

并删除暴露:

错误:

management:
  endpoints:
    web:
      exposure:
        include= "*"
      expose: "*"

正确:

management:
  endpoints:
    web:
      exposure:
        include: "*"

【讨论】:

猜你喜欢
  • 2019-05-12
  • 1970-01-01
  • 2016-09-07
  • 1970-01-01
  • 1970-01-01
  • 2020-06-14
  • 2023-04-04
  • 2018-10-15
  • 2018-06-16
相关资源
最近更新 更多