Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

 
Sheriff
Posts: 4868
317
IntelliJ IDE Python Java Linux
  • 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: 21950
106
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
Sheriff
Posts: 4868
317
IntelliJ IDE Python Java Linux
  • 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
Sheriff
Posts: 4868
317
IntelliJ IDE Python Java Linux
  • 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
 
Sheriff
Posts: 7616
522
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
Sheriff
Posts: 4868
317
IntelliJ IDE Python Java Linux
  • 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.
 
No holds barred. And no bars holed. Except this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic