How do I version my API with Spring MVC?

Now my API urls are:



With Spring MVC:



I would like to change this api:



Your best bet would be to use SpEL in annotation @RequestMapping

, but unfortunately this is not possible :



What are the other options?


source to share

2 answers

@RequestMapping resolves from place owner values. Therefore, define PropertySourcesPlaceHolderConfigurer as shown below.

<context:property-placeholder location="classpath*:*.properties"/>


Then use the syntax as shown below.





Try with @RequestMapping("/api-${version}/users")


See for details .



All Articles