I am trying to do the API versioning based on the below scenario. I have a package called V1 & V2, each has its own controller with Route mapping
@RequestMapping(path = "api/v${ApiVersion}/product")
public class ProductController {}
In the application.yml I have the below configuration,
ApiVersion: 1
spring:
profiles:
active: dev
server:
port: 8083
ApiVersion: 1
What I am trying to do is:
- If the URL has V1 (ApiVersion: 1) then it should route to V1 controller
http://192.168.1.101:8083/api/v1/product
- If the URL has V2 (ApiVersion: 2) then it should route to V2 controller
http://192.168.1.101:8083/api/v2/product
Is it possible to achieve?