How to show all available routes in Spring?

How to show all routes displayed in spring application? In Rails, this is done using rake routes.

I use two spring mapping methods to create URL mappings:

  • @RequestMapping
  • SimpleUrlHandler

I used the Unix grep and cut to get all @RequestMapping . I wonder if there is a way to get this data from a spring application.

+10
spring routes
source share
2 answers

If you set the Log4J category for log4j.logger.org.springframework.web to INFO or DEBUG , you should see a list of mappings in your server’s log (for example, catalina.out ) when your application starts.

For example:

 INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about] onto handler [ org.bozos.songfight.webapp.spring.controller.RootController@6bc9 47] INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about.*] onto handler [ org.bozos.songfight.webapp.spring.controller.RootController@6bc9 47] INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about/] onto handler [ org.bozos.songfight.webapp.spring.controller.RootController@6bc9 47] ... INFO: SimpleUrlHandlerMapping: Mapped URL path [/login] onto handler [ org.springframework.web.servlet.mvc.UrlFilenameViewController@40 35acf6] 
+8
source share

If you use Intellij (final version), then after creating / starting the project, you can view the routes in the bottom toolbar Run β†’ Endpoints β†’ Mappings .

enter image description here

+4
source share

All Articles