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

Spring Boot Actuator、Hal-Browser与DevTools均失效,附配置及报错信息

排查你的Spring Boot 404问题(Actuator + Hal Browser)

Hey there! Let's walk through why you're seeing those 404 errors when trying to access Actuator and Hal Browser endpoints. Since you mentioned your basic bean is working and printing output, your core Spring Boot app is starting up correctly—so the issue is almost certainly related to endpoint configuration or dependency setup.

1. Actuator Endpoint Path & Exposure Configuration (The /application 404)

First off, Spring Boot 2.x changed the default base path for Actuator endpoints from /application to /actuator. That's why hitting localhost:8080/application gives you a 404 right away. But even if you switch to /actuator, you might still see 404s because most endpoints are not exposed by default.

Fix this by adding these lines to your application.properties file:

# Optional: Set Actuator base path back to /application if you prefer it
management.endpoints.web.base-path=/application

# Expose all Actuator endpoints (adjust to specific ones like "health,info" if needed)
management.endpoints.web.exposure.include=*

# Optional: Show full health details for debugging
management.endpoint.health.show-details=always

After adding these, restart your app and try accessing localhost:8080/application (or /actuator if you skipped the base-path config) — you should see the Actuator JSON response now.

2. Hal Browser Setup (The /browser 404)

Hal Browser relies on Spring HATEOAS and proper Actuator integration to work. Let's check two key things:

a. Verify Your Dependency

Make sure you have the correct Hal Browser dependency in your pom.xml (the classic starter still works for most cases):

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-hal-browser</artifactId>
</dependency>

Double-check that this dependency is downloaded correctly (no red lines in your IDE, and Maven/Gradle sync completes without errors).

b. Ensure Actuator Endpoints Are Accessible

Hal Browser needs to pull data from Actuator endpoints to render its UI. If you fixed the Actuator exposure in step 1, the /browser endpoint should start working. If not, try accessing localhost:8080/browser/index.html directly (sometimes the root /browser redirect needs the full path).

c. Check for Path Conflicts

If you have any custom controllers mapping to /browser or /application, that could cause a conflict. Make sure none of your own beans are overriding these paths.

3. Quick Checks to Rule Out Other Issues

  • DevTools: DevTools shouldn't cause 404s, but if you're seeing weird caching glitches, try disabling it temporarily (comment out the dependency) to eliminate that variable. Its auto-restart feature is unlikely the root cause here.
  • Port Number: Double-check your app is running on port 8080 (look for the log line: Tomcat started on port(s): 8080 (http)). If it's using a different port, adjust your URL accordingly.
  • Bean Health: Since your custom bean is printing correctly, your Spring context is healthy—so we can rule out core startup failures.

Let's Dig Deeper If Needed

If you still hit 404s after these steps, share:

  • The exact error logs from your console when you try to access the endpoints
  • Your full pom.xml content (redact any sensitive info)
  • Your complete application.properties file

That way we can spot any missing dependencies or misconfigurations you might have missed.

内容的提问来源于stack exchange,提问作者Ankur Saxena

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:36:28