How to disable RepositoryRestHandlerMapping and EndpointHandlerMapping?

rabejens picture rabejens · Nov 4, 2014 · Viewed 9k times · Source

I am currently building an application with a REST interface, using Spring Boot, Hibernate and Spring-HATEOAS. My data model is defined as beans with @Entity annotation and I am using Spring's feature to automatically set up a Hibernate repository (Creating an interface extending PagingAndSortingRepository). My application is completely annotation-driven, i.e., I have no web.xml but configure everything with the Spring annotations like @Configuration, @Bean etc., and start the application from my main method with the help of SpringApplication.run(MyApp.class, args);

This works fine, but with this approach, a RepositoryRestHandlerMapping and EndpointHandlerMapping is created. These create a bunch of resources I neither need nor want. I implement my own controllers because they need to do more than the standard logic.

How can I prevent this default behaviour and disable these mappings?

Answer

Géza Alpári picture Géza Alpári · Oct 13, 2015

Exclude RepositoryRestMvcAutoConfiguration in your main class.

@EnableAutoConfiguration(exclude = RepositoryRestMvcAutoConfiguration.class)