Search code examples
springspring-mvcspring-data-rest

spring-data-rest-webmvc 2.0.0 - RepositoryRestExporterServlet missing


I'm trying to create a REST web service with spring-data-rest-webmvc 2.0.0. I'm following the handbook "Spring in Practice" where you use the version 1.0.0. In this handbook, it define the exporter servlet in web.xml as below:

<web-app ...>
    ...
    <servlet>
        <servlet-name>api</servlet-name>
        <servlet-class>org.springframework.data.rest.webmvc.RepositoryRestExporterServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>api</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
</web-app>

in version 2.0.0, I can not find the RepositoryRestExporterServlet class. What dispatcher servlet should I use? Where I can get some examples? Thanks


Solution

  • You can add

     <bean class="org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration"/>
    

    To your regular spring-mvc-servlet.xml config and then you can use both the REST servlet and Spring MVC servlet.

    Otherwise, for SDR 2, you should use:

    org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet

    in web.xml