title: Spring Boot route/path configuration
body: <p>I'm experiencing a little struggle with the route configuration. Here is my setup:</p>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>server.servlet.context-path=/MyApp
  </code></pre>
  
  <p><strong>IndexController.java</strong></p>
  
  <pre><code>@RestController
  public class IndexController {
  
  
    @GetMapping(path = "/")
    public ResponseEntity&lt;String&gt; getHelloWorld() {...}
  }
  </code></pre>
  
  <p><strong>SomethingAController.java</strong></p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/rest/api")
  public class SomethingAController {
  
  
    @GetMapping(path = "somethingA/all")
    public ResponseEntity&lt;List&lt;SomthingA&gt;&gt; getAll() {...}
    .
    .
    .
  }
  </code></pre>
  
  <p><strong>SomethingBController.java</strong></p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/rest/api")
  public class SomethingBController {
  
  
    @GetMapping(path = "somethingB/all")
    public ResponseEntity&lt;List&lt;SomthingB&gt;&gt; getAll() {...}
    .
    .
    .
  }
  </code></pre>
  
  <p>Soo.. what I'm trying to achieve is the following: </p>
  
  <ul>
  <li><p><code>/MyApp</code></p>
  
  <blockquote>
    <p>Simply returns "Hello World" (In a real world scenario there would be something a bit more sophisticated)</p>
  </blockquote></li>
  <li><p><code>/MyApp/rest/api/somethingA/all</code></p>
  
  <blockquote>
    <p>Returns the results of the SomethingAController getAll().</p>
  </blockquote></li>
  <li><p><code>/MyApp/rest/api/somethingB/all</code></p>
  
  <blockquote>
    <p>Returns the results of the SomethingBController getAll().</p>
  </blockquote></li>
  </ul>
  
  <p>I've tried a few things. </p>
  
  <p>Initially, I had the <code>server.servlet.context-path</code> set to <code>/MyApp/rest/api</code> and the <code>@RequestMapping</code> just set to <code>/</code>, which was working fine, but then there is no way of returning anything under just <code>/MyApp</code>.</p>
  
  <p>To be able to make use of <code>/MyApp</code>, I came up the setup which is described above, but for some reason this results in that the endpoints are not responding anymore. I'm still getting <code>200</code>s back, but with no data. </p>
  
  <p>After some playing around, I figured out that if I just set the <code>@RequestMapping</code> of the <code>SomethingAController</code> and <code>SomethingBController</code> to <code>/rest</code> or to <code>/api</code> that seems be working.</p>
  
  <p>Whilst it is nice that it is working the setting the <code>@RequestMapping</code> to either <code>/rest</code> or to <code>/api</code>, I'd like to configure it to <code>/rest/api</code>. This is not because that I think it is better, but rather to maintain an already existing REST interface.</p>
  
  <p>Using: </p>
  
  <ul>
  <li>spring-boot: 2.1.7.RELEASE</li>
  <li>jdk: 11</li>
  </ul>