if there are ten rest controllers in the spring boot application and each controller has 10 methods and I want to call 10th controller 9th method,
How spring boot does it efficiently internally ?
if there are ten rest controllers in the spring boot application and each controller has 10 methods and I want to call 10th controller 9th method,
How spring boot does it efficiently internally ?
What you are asking is managed by Spring MVC request mapping. Spring boot provides starter that autoconfigures Spring MVC.
In your case I suppose each method will be annotated with @RequestMapping (or one of its HTTP method specific shortcut variants like @GetMapping, @PostMapping, ...) You can find how @RequestMapping works in the spring documentation
To sumarize it, you have to annotate each method with @RequestMapping. Spring has a generic entry point (the dispatcher servlet) that intercept all incoming requests and forward them to the right controller.
@RestController
public class Controller1 {
@GetMapping("/endpoint1")
public String method1() {
return "Controller1.endpoint1";
}
@GetMapping("/endpoint2")
public String method2() {
return "Controller1.endpoint2";
}
}
Notice that Spring Mvc doesn't allow ambigous request mapping. You cannot have more than one method with the some request mapping url (Your application will not start)