Listing all deployed rest endpoints spring-boot, jersey
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Knowing all deployed REST endpoints in your application is essential for debugging, documentation, and API discovery. Spring Boot provides RequestMappingHandlerMapping to introspect all mapped routes, and the Actuator /mappings endpoint exposes this without writing code. For Jersey (JAX-RS), you can query the ResourceConfig or Application model at runtime to list all resource methods. Both frameworks also support custom startup listeners that log every registered endpoint when the application starts.
Spring Boot: RequestMappingHandlerMapping
This prints every mapped URL pattern, the HTTP methods it accepts, and the controller method that handles it.
Spring Boot Actuator /mappings Endpoint
The Actuator mappings endpoint returns a JSON document with every handler mapping, including Spring MVC controllers, resource handlers, and error mappings. No custom code required — just add spring-boot-starter-actuator as a dependency.
Spring Boot: ApplicationEventListener
Jersey (JAX-RS): Listing Resource Endpoints
Jersey with Spring Boot Integration
REST Endpoint Documentation with Swagger/OpenAPI
Springdoc-openapi auto-scans all Spring MVC and Jersey endpoints and generates a live OpenAPI specification. This is the most comprehensive approach for both discovery and documentation.
Common Pitfalls
- Forgetting to expose the Actuator mappings endpoint: By default, Spring Boot Actuator only exposes
health. You must addmanagement.endpoints.web.exposure.include=mappingsto see endpoint mappings. Without this, GET/actuator/mappingsreturns 404. - Missing child resources in Jersey listing: Jersey resources can have sub-resource locators that return other resource classes. Iterating only top-level
getResources()misses nested endpoints. Recursively traversegetChildResources()to capture the full tree. - Confusing Spring MVC and Jersey mappings in the same app: When both Spring MVC and Jersey are configured in the same application, they serve different URL prefixes. Spring MVC endpoints appear in
RequestMappingHandlerMapping, while Jersey endpoints appear in the JerseyResourceConfig. Query both to get a complete list. - Not accounting for path prefixes: Jersey typically runs under a servlet path like
/api/*. The resource@Pathannotations are relative to this prefix. When listing endpoints, prepend the servlet mapping path to get the actual URL. - Actuator endpoint security blocking access: Spring Security often protects Actuator endpoints. In production,
/actuator/mappingsmay return 401/403. Configure security rules to allow access for admin users or restrict it to internal networks only.
Summary
- Use
RequestMappingHandlerMapping.getHandlerMethods()to list all Spring MVC endpoints programmatically - Enable Spring Boot Actuator with
mappingsexposure for zero-code endpoint discovery via HTTP - For Jersey, iterate
ResourceConfig.getResources()recursively to capture all JAX-RS endpoints - Use springdoc-openapi for auto-generated, interactive API documentation with Swagger UI
- When both frameworks coexist, query both mapping systems to get a complete endpoint inventory
Related reading
- Liveness probe with http post
- Load balancer and API Gateway confusion
- Load uservoice API on Click
- Local Storage vs Cookies
- Load different application.yml in SpringBoot Test
- Loading classes and resources post Java 9
- Logging request/response messages when using HttpClient
- Logs complaining extensions/v1beta1 Ingress is deprecated

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.