Document auto-configuration packages and how to add to them
Closes gh-27549
This commit is contained in:
@@ -150,14 +150,14 @@ Note that each `configuration` sub namespace provides advanced settings based on
|
||||
[[howto.data-access.spring-data-repositories]]
|
||||
=== Use Spring Data Repositories
|
||||
Spring Data can create implementations of `@Repository` interfaces of various flavors.
|
||||
Spring Boot handles all of that for you, as long as those `@Repositories` are included in the same package (or a sub-package) of your `@EnableAutoConfiguration` class.
|
||||
Spring Boot handles all of that for you, as long as those `@Repositories` are included in one of the <<using#using.auto-configuration.packages,auto-configuration packages>>, typically the package (or a sub-package) of your main application class that is annotated with `@SpringBootApplication` or `@EnableAutoConfiguration`.
|
||||
|
||||
For many applications, all you need is to put the right Spring Data dependencies on your classpath.
|
||||
There is a `spring-boot-starter-data-jpa` for JPA, `spring-boot-starter-data-mongodb` for Mongodb, and various other starters for supported technologies.
|
||||
To get started, create some repository interfaces to handle your `@Entity` objects.
|
||||
|
||||
Spring Boot tries to guess the location of your `@Repository` definitions, based on the `@EnableAutoConfiguration` it finds.
|
||||
To get more control, use the `@EnableJpaRepositories` annotation (from Spring Data JPA).
|
||||
Spring Boot determines the location of your `@Repository` definitions by scanning the <<using#using.auto-configuration.packages,auto-configuration packages>>.
|
||||
For more control, use the `@Enable…Repositories` annotations from Spring Data.
|
||||
|
||||
For more about Spring Data, see the {spring-data}[Spring Data project page].
|
||||
|
||||
@@ -165,8 +165,8 @@ For more about Spring Data, see the {spring-data}[Spring Data project page].
|
||||
|
||||
[[howto.data-access.separate-entity-definitions-from-spring-configuration]]
|
||||
=== Separate @Entity Definitions from Spring Configuration
|
||||
Spring Boot tries to guess the location of your `@Entity` definitions, based on the `@EnableAutoConfiguration` it finds.
|
||||
To get more control, you can use the `@EntityScan` annotation, as shown in the following example:
|
||||
Spring Boot determines the location of your `@Entity` definitions by scanning the <<using#using.auto-configuration.packages,auto-configuration packages>>.
|
||||
For more control, use the `@EntityScan` annotation, as shown in the following example:
|
||||
|
||||
include::code:MyApplication[]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user