【问题标题】:Spring Boot Actuator empty responseSpring Boot Actuator 空响应
【发布时间】:2021-12-09 22:36:05
【问题描述】:

Spring Boot 应用具有以下网络安全配置:

@EnableWebSecurity
@Configuration
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter
{
   @Override
   public void configure(WebSecurity web) throws Exception
   {
      web.ignoring().antMatchers("/actuator/**");
   }

   @Override
   protected void configure(HttpSecurity http) throws Exception
   {
      http.authorizeRequests().antMatchers("/").permitAll();

      http.csrf().disable();
   }
}

application.properites:

management.endpoints.web.exposure.include=health,info,loggers
management.endpoints.web.base-path=/actuator
management.endpoint.health.show-details=always

启动应用程序后,我可以在日志中看到:

[ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 3 endpoint(s) beneath base path '/actuator'

然后:

bash-5.1$ curl -I --header 'Content-Type: application/json' -X "GET" "http://localhost:8083/actuator/health"
HTTP/1.1 200
Content-Type: application/vnd.spring-boot.actuator.v3+json
Transfer-Encoding: chunked
Date: Thu, 09 Dec 2021 22:26:48 GMT

有什么想法为什么它会空着回来吗?

【问题讨论】:

    标签: spring-boot curl spring-boot-actuator


    【解决方案1】:

    因为:

    curl --help all
    

    ...说:

    ...
     -I, --head               Show document info only
    ...
    

    ;)


    所以:

    curl --header 'Content-Type: application/json' -X "GET" "http://localhost:8083/actuator/health"
    

    (省略-I)我们得到了预期:

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   171    0   171    0     0  32540      0 --:--:-- --:--:-- --:--:-- 42750
    {"status":"UP","components":{"diskSpace":{"status":"UP","details":{"total":1991571578880,"free":1684774006784,"threshold":10485760,"exists":true}},"ping":{"status":"UP"}}}
    

    【讨论】:

    • 愚蠢的我在调试 401s 后离开了它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-02
    • 2019-03-26
    • 1970-01-01
    • 1970-01-01
    • 2016-06-01
    • 2016-06-19
    相关资源
    最近更新 更多