You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot Actuator:配置禁用后仍无法屏蔽/health端点的问题

Troubleshooting Unblocked /health Endpoint Despite Configuration

Hey there! Let's dig into why your /health endpoint is still accessible even after setting endpoints.enabled=false and endpoints.health.enabled=false in your application.properties. This usually boils down to Spring Boot version differences or unexpected configuration overrides—here's how to fix it:

1. Check Your Spring Boot Version (Critical!)

The configuration keys for Actuator endpoints changed drastically between Spring Boot 1.x and 2.x:

  • If you're on Spring Boot 2.x+: The old endpoints.* properties are deprecated and won't work. You need to use the management.* prefix instead:
    • To block only the /health endpoint:
      management.endpoints.web.exposure.exclude=health
      management.health.enabled=false
      
    • To block all Actuator endpoints entirely:
      management.endpoints.web.exposure.include=none
      management.health.enabled=false
      
  • If you're on Spring Boot 1.x: Your original properties should work, but double-check if any other configuration is overriding them (see point 2 below).

2. Look for Configuration Overrides

  • Check if you have profile-specific property files (like application-dev.properties or application-prod.properties) that might be overriding the main application.properties settings.
  • Verify if any custom @Configuration classes are manually enabling the health endpoint—for example, using @Endpoint(id = "health") or @WebEndpoint(id = "health") annotations that bypass the property settings.

3. Confirm the /health Endpoint Origin

Is the accessible /health actually the Actuator endpoint? Sometimes projects define custom /health endpoints outside of Spring Boot Actuator. To confirm:

  • Check your dependencies: If you don't have spring-boot-starter-actuator in your pom.xml or build.gradle, the endpoint is likely custom—you'll need to disable it in your controller/endpoint code.

4. Verify Configuration Loading

To ensure your properties are being picked up correctly:

  • For Spring Boot 2.x, access the /actuator/env endpoint (if it's enabled) and search for your health-related properties to see if they're active.
  • Check your application startup logs for lines mentioning "health endpoint" or property loading—this can reveal if your settings are being ignored or overridden.

5. Clean and Rebuild

Sometimes stale build artifacts can cause configuration issues. Try cleaning your project (e.g., mvn clean or ./gradlew clean) and rebuilding it before restarting the application.


内容的提问来源于stack exchange,提问作者tindu edward

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:51:58