Spring Data Rest base path

spring-data-rest

Solution

I solved my problem by adding a second "AbstractAnnotationConfigDispatcherServletInitializer":

public class RestWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return null;
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[] { RepositoryRestMvcConfiguration.class };
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/rest/*" };
    }

    @Override
    protected Filter[] getServletFilters() {
        return null;
    }

    @Override
    protected String getServletName() {
        return "rest-exporter";
    }
}

Problem

I have added Spring Data Rest (2.0) to an existing Spring MVC application by creating a Java config class that extends RepositoryRestMvcConfiguration, and adding @RestResource to the repositories. Is it possible to change the base URL for the Rest API? E.g: ``` http://localhost:8080/rest/customers ``` instead of ``` http://localhost:8080/customers ``` I tried to override configureRepositoryRestConfiguration using setBaseURI, but it didn't seem to apply to all links in the response.

Original source

Related problems