@EnableJpaRepositories is a configuration-class annotation that turns on Spring Data JPA's repository support, telling Spring which package(s) to scan for repository interfaces so it can generate their implementations automatically at startup.
In a multi-module Spring application where repository interfaces live in a separate library module outside the main application's package tree, @EnableJpaRepositories(basePackages = "com.company.repository") tells Spring exactly where to look for them.
@Configuration
@EnableJpaRepositories(basePackages = "com.company.repository")
public class JpaConfig {
}A concise interview answer is
@EnableJpaRepositories tells Spring which packages to scan for repository interfaces so it can generate their implementations at startup. Spring Boot auto-configures this for you in the common case, so I only need to declare it explicitly when repositories live outside the default component-scanned package, like in a multi-module project.
Last updated: 11 November 2026
Previous question: How do you create a composite primary key in Spring Data JPA?
Next question: What rules must custom query methods in a Spring Data repository follow?