Home > Mobile >  What is the very first function which is called during a rest api call in spring boot?
What is the very first function which is called during a rest api call in spring boot?

Time:03-04

I would like to set a breakpoint for debugging purpose. I call a rest api from Postman and I would like to check the very first point where the java application gets the call. Is there a listener? Where to set the breakpoint?

CodePudding user response:

I guess the DispatcherServlet is what you are looking for. There is a lot of other stuff running before e.g. the servlet container and potential servlet filter, but the DispatcherServlet is a good starting point for debugging Spring MVC issues.

protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception

The documentation is also quite good: https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-servlet

For Spring MVC Webflux applications have a look at DispatcherHandler and set a breakpoint in public Mono<Void> handle(ServerWebExchange exchange).

  • Related