Spring Data Rest base path
You can configure the RepositoryRestMvcConfiguration
by overriding it in the following manner:
@Configuration
@Import(RepositoryRestMvcConfiguration.class)
public class RestDataConfig extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
super.configureRepositoryRestConfiguration(config);
try {
config.setBaseUri(new URI("/data"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
As of Spring Boot 1.2 you are able to set this property:
spring.data.rest.baseUri=api
Alternatively:
spring.data.rest.base-uri=api
(Spring Boot uses a relaxed binding system)
NOTE: I have found that if you have extended RepositoryRestMvcConfiguration
with custom configuration, the property does not take effect. For more information see:
https://github.com/spring-projects/spring-boot/issues/2392
Once the next version of Spring Boot is released (after 1.2.1), the solution will be to extend RepositoryRestMvcBootConfiguration
instead.
Add to following line to application.properties(Spring boot version 2.2.0.M2)
spring.mvc.servlet.path=/rest
Hope this helps
I used spring boot 1.2.3.REALEASE
I tried spring.data.rest.baseUri=/api
and spring.data.rest.basePath=/api
but it not working.
After try and googling: server.servlet-path=/api
worked for me.