How do I version my API with Spring MVC?
Now my API urls are:
/api/users
With Spring MVC:
@RequestMapping("/api/users")
I would like to change this api:
/api-v1.0/users
Your best bet would be to use SpEL in annotation @RequestMapping
, but unfortunately this is not possible :
@RequestMapping("/api-#{appProps['version']}/users")
What are the other options?
+3
source to share
2 answers
Try with @RequestMapping("/api-${version}/users")
.
See http://docs.spring.io/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping-placeholders for details .
+3
source to share