Skip to content

Commit ce1f8d4

Browse files
committed
Merge branch '2.7.x' into 3.0.x
Closes gh-38052
2 parents 627c93a + 1498faa commit ce1f8d4

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ You could take the JPA example from earlier and, assuming that `City` is now a M
155155
include::code:CityRepository[]
156156

157157
Repositories and documents are found through scanning.
158-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
158+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
159159
You can customize the locations to look for repositories and documents by using `@EnableMongoRepositories` and `@EntityScan` respectively.
160160

161161
TIP: For complete details of Spring Data MongoDB, including its rich object mapping technologies, see its {spring-data-mongodb}[reference documentation].
@@ -211,7 +211,7 @@ Spring Boot supports both classic and reactive Neo4j repositories, using the `Ne
211211
When Project Reactor is available on the classpath, the reactive style is also auto-configured.
212212

213213
Repositories and entities are found through scanning.
214-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
214+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
215215
You can customize the locations to look for repositories and entities by using `@EnableNeo4jRepositories` and `@EntityScan` respectively.
216216

217217
[NOTE]
@@ -323,7 +323,7 @@ In fact, both Spring Data JPA and Spring Data Elasticsearch share the same commo
323323
You could take the JPA example from earlier and, assuming that `City` is now an Elasticsearch `@Document` class rather than a JPA `@Entity`, it works in the same way.
324324

325325
Repositories and documents are found through scanning.
326-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
326+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
327327
You can customize the locations to look for repositories and documents by using `@EnableElasticsearchRepositories` and `@EntityScan` respectively.
328328

329329
TIP: For complete details of Spring Data Elasticsearch, see the {spring-data-elasticsearch-docs}[reference documentation].
@@ -411,7 +411,7 @@ Spring Data includes basic repository support for Cassandra.
411411
Currently, this is more limited than the JPA repositories discussed earlier and needs `@Query` annotated finder methods.
412412

413413
Repositories and entities are found through scanning.
414-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
414+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
415415
You can customize the locations to look for repositories and entities by using `@EnableCassandraRepositories` and `@EntityScan` respectively.
416416

417417
TIP: For complete details of Spring Data Cassandra, see the https://docs.spring.io/spring-data/cassandra/docs/[reference documentation].
@@ -466,7 +466,7 @@ To take more control, one or more `ClusterEnvironmentBuilderCustomizer` beans ca
466466
Spring Data includes repository support for Couchbase.
467467

468468
Repositories and documents are found through scanning.
469-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
469+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
470470
You can customize the locations to look for repositories and documents by using `@EnableCouchbaseRepositories` and `@EntityScan` respectively.
471471

472472
For complete details of Spring Data Couchbase, see the {spring-data-couchbase-docs}[reference documentation].
@@ -536,7 +536,7 @@ Make sure to flag your customized `ContextSource` as `@Primary` so that the auto
536536
Spring Data includes repository support for LDAP.
537537

538538
Repositories and documents are found through scanning.
539-
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
539+
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
540540
You can customize the locations to look for repositories and documents by using `@EnableLdapRepositories` and `@EntityScan` respectively.
541541

542542
For complete details of Spring Data LDAP, see the https://docs.spring.io/spring-data/ldap/docs/1.0.x/reference/html/[reference documentation].

spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ You can follow the https://spring.io/guides/gs/accessing-data-jpa/["`Accessing D
195195
==== Entity Classes
196196
Traditionally, JPA "`Entity`" classes are specified in a `persistence.xml` file.
197197
With Spring Boot, this file is not necessary and "`Entity Scanning`" is used instead.
198-
By default, all packages below your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) are searched.
198+
By default the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
199199

200200
Any classes annotated with `@Entity`, `@Embeddable`, or `@MappedSuperclass` are considered.
201201
A typical entity class resembles the following example:
@@ -216,7 +216,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
216216
For more complex queries, you can annotate your method with Spring Data's {spring-data-jpa-api}/repository/Query.html[`Query`] annotation.
217217

218218
Spring Data repositories usually extend from the {spring-data-commons-api}/repository/Repository.html[`Repository`] or {spring-data-commons-api}/repository/CrudRepository.html[`CrudRepository`] interfaces.
219-
If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) down.
219+
If you use auto-configuration, the <<using#using.auto-configuration.packages,auto-configuration packages>> are searched for repositories.
220220

221221
TIP: You can customize the locations to look for repositories using `@EnableJpaRepositories`.
222222

@@ -506,7 +506,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
506506
For more complex queries, you can annotate your method with Spring Data's {spring-data-r2dbc-api}/repository/Query.html[`Query`] annotation.
507507

508508
Spring Data repositories usually extend from the {spring-data-commons-api}/repository/Repository.html[`Repository`] or {spring-data-commons-api}/repository/CrudRepository.html[`CrudRepository`] interfaces.
509-
If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) down.
509+
If you use auto-configuration, the <<using#using.auto-configuration.packages,auto-configuration packages>> are searched for repositories.
510510

511511
The following example shows a typical Spring Data repository interface definition:
512512

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,23 @@ Note that each `configuration` sub namespace provides advanced settings based on
150150
[[howto.data-access.spring-data-repositories]]
151151
=== Use Spring Data Repositories
152152
Spring Data can create implementations of `@Repository` interfaces of various flavors.
153-
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.
153+
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`.
154154

155155
For many applications, all you need is to put the right Spring Data dependencies on your classpath.
156156
There is a `spring-boot-starter-data-jpa` for JPA, `spring-boot-starter-data-mongodb` for Mongodb, and various other starters for supported technologies.
157157
To get started, create some repository interfaces to handle your `@Entity` objects.
158158

159-
Spring Boot tries to guess the location of your `@Repository` definitions, based on the `@EnableAutoConfiguration` it finds.
160-
To get more control, use the `@EnableJpaRepositories` annotation (from Spring Data JPA).
159+
Spring Boot determines the location of your `@Repository` definitions by scanning the <<using#using.auto-configuration.packages,auto-configuration packages>>.
160+
For more control, use the `@Enable…Repositories` annotations from Spring Data.
161161

162162
For more about Spring Data, see the {spring-data}[Spring Data project page].
163163

164164

165165

166166
[[howto.data-access.separate-entity-definitions-from-spring-configuration]]
167167
=== Separate @Entity Definitions from Spring Configuration
168-
Spring Boot tries to guess the location of your `@Entity` definitions, based on the `@EnableAutoConfiguration` it finds.
169-
To get more control, you can use the `@EntityScan` annotation, as shown in the following example:
168+
Spring Boot determines the location of your `@Entity` definitions by scanning the <<using#using.auto-configuration.packages,auto-configuration packages>>.
169+
For more control, use the `@EntityScan` annotation, as shown in the following example:
170170

171171
include::code:MyApplication[]
172172

spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ TIP: You can define exclusions both at the annotation level and by using the pro
3535

3636
NOTE: Even though auto-configuration classes are `public`, the only aspect of the class that is considered public API is the name of the class which can be used for disabling the auto-configuration.
3737
The actual contents of those classes, such as nested configuration classes or bean methods are for internal use only and we do not recommend using those directly.
38+
39+
40+
[[using.auto-configuration.packages]]
41+
=== Auto-configuration Packages
42+
Auto-configuration packages are the packages that various auto-configured features look in by default when scanning for things such as entities and Spring Data repositories.
43+
The `@EnableAutoConfiguration` annotation (either directly or through its presence on `@SpringBootApplication`) determines the default auto-configuration package.
44+
Additional packages can be configured using the `@AutoConfigurationPackage` annotation.

0 commit comments

Comments
 (0)