title: Spring boot: how to set a common path for multiple RestControllers
body: <p>I am using spring boot to write an api and I would like to map all my resources behind a common base path (/api in this case). However I don't want to annotate each RestController class to do this (by annotating it with @RequestMapping for example).
  I have thought about the following solutions but they all have a down side that i would rather not want:</p>
  
  <ul>
  <li>Creating a base class (eg ApiRestController) and having all the other RestController inherit this one. This has as disadvantage that @Requestmapping on the class level isn't merged between the base and implementing classes.</li>
  <li>Annotating all the RestController but this leads to code duplication</li>
  <li>Changing the server.context-path property. This has as disadvantage that all endpoints will use this base path. Even the endpoints exposed by the actuator project.</li>
  <li>Using a custom DispatcherServlet and ServletRegistrationBean. But this seems to have the same effect as changing the server.context-path.</li>
  </ul>
  
  <p>So does anyone know how to do this without the disadvantages the solutions have that i summed. The project will only expose a REST-based backend and will not server any static content (don't know if this influences the possible solutions). The Restcontrollers are also divided over multiple packages.</p>
  
  <p>Thanks.</p>