I am starting a new Spring Boot web project and want to nest @RestController
inside of each other to have a structure for my v1, v2, etc, API and other endpoints that may come along and have the child obtain the path from their parent. For example:
@RestController
@RequestMapping("/api")
public class RootAPIController {
}
@RestController
@RequestMapping("/v1")
public class RootV1Controller extends RootAPIController {
}
to the final path like this:
@RestController
@RequestMapping("/card")
public class CardController extends RootV1Controller {
@GetMapping(value = "/all", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> getCards() {
return new ResponseEntity<>("", HttpStatus.OK);
}
}
But Spring doesn't seem to be exposing my URL's at all, all I'm getting is a 404 back when trying any of them.
@SpringBootApplication
public class BackendServiceApplication {
public static void main(String[] args) {
SpringApplication.run(BackendServiceApplication.class, args);
}
}
All of my classes are in children under the main package that the SpringBootApplication
sits at, from what I have read it should pick those up if they are under it, but it just won't for the ones that are outside of it. What am I missing here?
Thanks!