I have several REST endpoints in my Spring Boot application. We are currently using JAX-RS / Apache CXF (using javax.ws.rs.Path annotation in our Facade REST endpoint classes) and are currently migrating to to Spring REST (MVC). Due to big number of endpoint classes, we have structure like:
com.example.domain1.Facade1.java - @Path("facade1path)
com.example.domain1.Facade2.java - @Path("facade2path)
... (much more "Facade" classes in com.example.domain1 package)
com.example.domain2.Facade3.java - @Path("facade3path)
com.example.domain2.Facade4.java - @Path("facade4path)
... (much more "Facade" classes in com.example.domain2 package)
And we have the application configured in a way that paths are set to:
"/api/domain1/facade1path" -> Facade1.java
"/api/domain1/facade2path" -> Facade2.java
"/api/domain2/facade3path" -> Facade3.java
"/api/domain2/facade4path" -> Facade4.java
With old JAX-RS / CXF configuration, we were able to achieve this in quite elegant way, without having to repeat "/api/domain1/" or "/api/domain2/ in all @Path annotations. We have set up multiple "jaxrs-server" elements in specific CXF configuration in this way:
<jaxrs:server id="Domain1Server" address="/api/domain1" basePackages="com.example.domain1" />
<jaxrs:server id="Domain2Server" address="/api/domain2" basePackages="com.example.domain2" />
And it works :-)
Is there any way how to achieve something similar with Spring REST / MVC, without having to repeat "api/domain1" or "api/domain2" in annotations in multiple controller classes -
@RequestMapping("api/domain1/facade1path"), @RequestMapping("api/domain1/facade2path"),
etc.?
Have not found any kind of resources indicating that this would be somehow possible with Spring so far, maybe it is not possible, but it would be nice if there is some hack how to do it :-)
Thanks in advance, anyone!