• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How can I have Spring print out all web api endpoint details?

 
Marshal
Posts: 4671
305
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Spring Boot app and part of the log output during startup looks like this:

Is there a maven goal for Spring or something that I can use to print this information? I'd like to be able to easily script an up to date report of my current api.
 
Greenhorn
Posts: 4
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be you should take a look into spring boot actuators. It provides many endpoints out of the box.
 
Sheriff
Posts: 21788
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find the out-of-the-box actuators at https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html. In this case, the mappings one seems to be what you need, but its output is quite verbose.
 
Tim Cooke
Marshal
Posts: 4671
305
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had not heard of Actuators before so that's good information. However, I must be trying to access it incorrectly or my app has them disabled because hitting this just returns 404
 
Dhiraj Ray
Greenhorn
Posts: 4
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check if you have the right dependency included in your pom.xml or else visit https://www.devglan.com/spring-security/securing-spring-boot-actuator-endpoints-with-spring-security for actuator configuration and accessing actuator endpoints.
 
Tim Cooke
Marshal
Posts: 4671
305
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not have the right dependency. Now I do and it's working a treat! Thanks Dhiraj
 
Marshal
Posts: 7084
491
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also you could use your Spring Boot app along with Swagger, which could be used for auto built RESTful API docs:

And having defined configuration in your Spring Boot app:

Access documentation: REST-URL:PORT/swagger-ui.html <-- could map to something more descriptive of course.

Not exactly sure whether it is what you are looking for though.
 
Tim Cooke
Marshal
Posts: 4671
305
IntelliJ IDE Clojure Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras, if I were in London right now I'd come round your house and hug you.

This is perfect! Thank you.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!