How to exclude a @Repository from component scan when using Spring Data Rest

You can use annotation over your repository interface. From doc:

Annotation to exclude repository interfaces from being picked up and thus in consequence getting an instance being created.

This will typically be used when providing an extended base interface for all repositories in combination with a custom repository base class to implement methods declared in that intermediate interface. In this case you typically derive your concrete repository interfaces from the intermediate one but don't want to create a Spring bean for the intermediate interface.

Because it's a repository and not strictly a @Component, you need to excluded it by adding @EnableJpaRepositories to your application:

@EnableJpaRepositories(excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
public class ApiApplication {

    public static void main(String[] args) {, args);