In Spring Boot about JPA and Spring Data JPA, exists in the current reference documentation the JPA and Spring Data JPA section, where it has two sub-sections as follows:
These 2 sections have the following content respectively:
By default, all packages below your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) are searched
and
If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) down
For Spring Boot 3.1.1 working with Spring Data JPA the @EntityScan and @EnableJpaRepositories annotations are not necessary to be declared explicitly, only if the packages where the Entities and Repositories are defined, reside within the package containing the main configuration class. I think it should be declared explicitly for each documentation section, according the respective annotation.
Of course, if any of these types (Entities or Repositories) are defined in a package different of the package containing the main configuration class then the respective annotation is mandatory to be declared. Other scenario would be if for @EnableJpaRepositories is need it define some extra configuration, it such as repositoryImplementationPostfix
Therefore an expansion about when to declare or not these annotations to the current Reference Documentation would be valuable.
Thanks for your understanding
In Spring Boot about JPA and Spring Data JPA, exists in the current reference documentation the JPA and Spring Data JPA section, where it has two sub-sections as follows:
These 2 sections have the following content respectively:
and
For Spring Boot 3.1.1 working with Spring Data JPA the
@EntityScanand@EnableJpaRepositoriesannotations are not necessary to be declared explicitly, only if the packages where the Entities and Repositories are defined, reside within the package containing the main configuration class. I think it should be declared explicitly for each documentation section, according the respective annotation.Of course, if any of these types (Entities or Repositories) are defined in a package different of the package containing the main configuration class then the respective annotation is mandatory to be declared. Other scenario would be if for
@EnableJpaRepositoriesis need it define some extra configuration, it such as repositoryImplementationPostfixTherefore an expansion about when to declare or not these annotations to the current Reference Documentation would be valuable.
Thanks for your understanding