We have some already developed REST APIs in SpringBoot.
Now we want to prepend some text (version of API eg /v1/) to all the @RequestMapping.
Is there any way of doing this except prepending /v1/ to every @RequestMapping
example: Current RequestMapping /employess and /cars/1/driver
Need to build like this /v1/employess and /v1/cars/1/driver
You can use such property in your application.properties file:
server.servlet.contextPath=/v1
or you can have a base controller class and extend it with all your controller classes
@RestController
@RequestMapping(value = "${rest.api.version}")
public class MyAbstractController {
}
and store rest.api.version in your application.properties file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With