【问题标题】:spring boot actuator endpoints unavailable after (2.5) uprade(2.5)升级后弹簧启动执行器端点不可用
【发布时间】:2021-09-07 08:33:20
【问题描述】:

我已尝试接受针对类似问题提供的建议;无济于事。有人可以解释一下这个问题的解决方案吗,就像我六岁一样?

我已将我的 Spring Boot 版本升级到 2.5。我的套件中的所有测试仍然通过,除了这个 @Springboot 测试:

@Test
void readActuatorInfo_success() throws Exception {
    mockMvc.perform(
            get("/actuator/info")
                    .header("Authorization", "Basic dXNlcjpwYXNzd29yZA=="))
            .andExpect(status().isOk());
}

它失败了,因为响应是 404。现在,我知道 springboot 默认情况下不会暴露端点,它们必须显式配置。例如,下面的 yaml 应该这样做,但没有。有什么建议吗?

application:
   endpoint:
     info:
       enabled: true

需要明确的是,Springboot 2.3 通过了这个测试

【问题讨论】:

    标签: spring-boot spring-boot-actuator


    【解决方案1】:

    从 2.5 开始,Info 端点默认不再公开,

    默认情况下,/info 执行器端点不再在 Web 上公开。此外,如果 Spring Security 在类路径上并且您的应用程序没有自定义安全配置,则默认情况下端点需要经过身份验证的访问。

    请参阅有关公开和保护执行器端点的文档以更改这些新默认值。

    https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5-Release-Notes#secure-info-endpoint

    management:
       endpoint:
          web:
            exposure: "health,info"
    

    【讨论】:

    • 我仍然收到 404。我可以确认我的 yaml 文件确实在使用中,并且它包含您的配置。我显然做错了什么,我会重新开始。
    • 对不起,这是错误的属性是为什么:) 更新
    • 谢谢,但现在我明白了:...引起:org.springframework.beans.factory.BeanCreationException:创建类路径资源中定义的名称为“springSecurityFilterChain”的bean时出错[org/springframework/ security/config/annotation/web/configuration/WebSecurityConfiguration.class]:通过工厂方法的 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [javax.servlet.Filter]:工厂方法“springSecurityFilterChain”抛出异常;嵌套异常是 java.lang.IllegalArgumentException: ...
    • 引起:java.lang.IllegalArgumentException:defaultTarget 必须以 '/' 或 org.springframework.util.Assert.isTrue(Assert.java:121) 中的 'http(s)' 开头/跨度>
    • 请添加完整的堆栈和您的网络安全配置
    猜你喜欢
    • 2018-01-07
    • 2020-06-17
    • 2022-08-03
    • 1970-01-01
    • 2015-03-08
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    • 1970-01-01
    相关资源
    最近更新 更多