Spring Boot 1.5.9.RELEASE Actuator默认端点未启动求助
Hey there, let's figure out why your /info, /metrics, and /health endpoints are returning 404. I've run into this exact issue a few times with Spring Boot 1.5.x, so here are the most common fixes to work through:
1. Double-Check Your Actuator Dependency
First, confirm your pom.xml has the correct Actuator starter dependency. For Spring Boot 1.5.9, it should look like this:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
If this is missing, misspelled, or using a wrong group ID, the Actuator endpoints won't register at all.
2. Verify Your Endpoint URLs Match Configuration
Spring Boot 1.5.x has two key path settings that can throw off your endpoint URLs:
- Server Context Path: If you set
server.context-path=/my-appinapplication.properties, you need to prepend this to your endpoint URLs (e.g.,http://localhost:8080/my-app/infoinstead of just/info). - Management Context Path: If you added
management.context-path=/manage, all Actuator endpoints will live under this prefix (e.g.,http://localhost:8080/manage/health).
Make sure you're hitting the full, correct URL based on your config.
3. Ensure Endpoints Aren't Accidentally Disabled
Even though /info, /health, and /metrics are enabled by default, it's easy to accidentally turn them off. Check your application.properties for any lines like:
# Disables all Actuator endpoints (remove this if present) endpoints.enabled=false # Disables individual endpoints (look for these too) endpoints.info.enabled=false endpoints.health.enabled=false endpoints.metrics.enabled=false
If any of these exist, comment them out or delete them to re-enable the endpoints.
4. Check Startup Logs for Actuator Registration
Since you've set org.springframework to INFO level, your startup logs should show lines confirming Actuator endpoints are mapped. Look for entries like:
Mapped "{[/info],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.InfoMvcEndpoint.info()
If you don't see these lines, it means Actuator isn't being loaded at all—this almost always points to a missing dependency or conflicting configuration.
5. Rule Out Custom Web Config Blocking Endpoints
If you have a custom WebMvcConfigurerAdapter or DispatcherServlet setup, make sure it's not restricting path mappings to a specific prefix (like /api/*). Actuator endpoints use their own paths, so if your config only handles requests under a narrow prefix, Actuator paths will be ignored.
For example, if you have code like this in a config class:
@Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class)); }
This won't affect Actuator (since it uses @Endpoint instead of @RestController), but more restrictive setups could block the endpoints.
6. Check for Security Config Edge Cases
Normally Spring Security would return 403 (Forbidden) instead of 404 for Actuator endpoints, but if you have a security filter that rewrites or redirects URLs incorrectly, it could lead to a 404. If you're using spring-boot-starter-security, add a rule to allow access to Actuator endpoints:
@Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/info", "/health", "/metrics").permitAll() .anyRequest().authenticated(); }
This is a long shot for 404, but worth checking if other fixes don't work.
Start with the first three checks—dependency, path config, and endpoint enabled status—since those are the most common culprits for 404s in Spring Boot 1.5.x Actuator.
内容的提问来源于stack exchange,提问作者user3335083

