title: Api versioning in spring boot
body: <p>I am trying to do the API versioning based on the below scenario. I have a package called <strong>V1</strong> &amp; <strong>V2</strong>, each has its own controller with Route mapping</p>
  <pre><code>@RequestMapping(path = &quot;api/v${ApiVersion}/product&quot;)
  public class ProductController {}
  </code></pre>
  <p>In the application.yml I have the below configuration,</p>
  <p><strong>ApiVersion: 1</strong></p>
  <pre><code>spring:
    profiles:
      active: dev
  server:
    port: 8083
  
  ApiVersion: 1
  </code></pre>
  <p><a href="https://i.stack.imgur.com/IwYn7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IwYn7.png" alt="enter image description here" /></a></p>
  <p>What I am trying to do is:</p>
  <ol>
  <li>If the URL has V1 <strong>(ApiVersion: 1)</strong> then it should route to V1 controller <code>http://192.168.1.101:8083/api/v1/product</code></li>
  <li>If the URL has V2 <strong>(ApiVersion: 2)</strong> then it should route to V2 controller <code>http://192.168.1.101:8083/api/v2/product</code></li>
  </ol>
  <p>Is it possible to achieve?</p>