You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,7 +155,7 @@ You could take the JPA example from earlier and, assuming that `City` is now a M
155
155
include::code:CityRepository[]
156
156
157
157
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.
159
159
You can customize the locations to look for repositories and documents by using `@EnableMongoRepositories` and `@EntityScan` respectively.
160
160
161
161
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
211
211
When Project Reactor is available on the classpath, the reactive style is also auto-configured.
212
212
213
213
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.
215
215
You can customize the locations to look for repositories and entities by using `@EnableNeo4jRepositories` and `@EntityScan` respectively.
216
216
217
217
[NOTE]
@@ -323,7 +323,7 @@ In fact, both Spring Data JPA and Spring Data Elasticsearch share the same commo
323
323
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.
324
324
325
325
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.
327
327
You can customize the locations to look for repositories and documents by using `@EnableElasticsearchRepositories` and `@EntityScan` respectively.
328
328
329
329
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.
411
411
Currently, this is more limited than the JPA repositories discussed earlier and needs `@Query` annotated finder methods.
412
412
413
413
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.
415
415
You can customize the locations to look for repositories and entities by using `@EnableCassandraRepositories` and `@EntityScan` respectively.
416
416
417
417
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
466
466
Spring Data includes repository support for Couchbase.
467
467
468
468
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.
470
470
You can customize the locations to look for repositories and documents by using `@EnableCouchbaseRepositories` and `@EntityScan` respectively.
471
471
472
472
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
536
536
Spring Data includes repository support for LDAP.
537
537
538
538
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.
540
540
You can customize the locations to look for repositories and documents by using `@EnableLdapRepositories` and `@EntityScan` respectively.
541
541
542
542
For complete details of Spring Data LDAP, see the https://docs.spring.io/spring-data/ldap/docs/1.0.x/reference/html/[reference documentation].
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/sql.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -195,7 +195,7 @@ You can follow the https://spring.io/guides/gs/accessing-data-jpa/["`Accessing D
195
195
==== Entity Classes
196
196
Traditionally, JPA "`Entity`" classes are specified in a `persistence.xml` file.
197
197
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.
199
199
200
200
Any classes annotated with `@Entity`, `@Embeddable`, or `@MappedSuperclass` are considered.
201
201
A typical entity class resembles the following example:
@@ -216,7 +216,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
216
216
For more complex queries, you can annotate your method with Spring Data's {spring-data-jpa-api}/repository/Query.html[`Query`] annotation.
217
217
218
218
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.
220
220
221
221
TIP: You can customize the locations to look for repositories using `@EnableJpaRepositories`.
222
222
@@ -506,7 +506,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
506
506
For more complex queries, you can annotate your method with Spring Data's {spring-data-r2dbc-api}/repository/Query.html[`Query`] annotation.
507
507
508
508
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.
510
510
511
511
The following example shows a typical Spring Data repository interface definition:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/data-access.adoc
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,23 +150,23 @@ Note that each `configuration` sub namespace provides advanced settings based on
150
150
[[howto.data-access.spring-data-repositories]]
151
151
=== Use Spring Data Repositories
152
152
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`.
154
154
155
155
For many applications, all you need is to put the right Spring Data dependencies on your classpath.
156
156
There is a `spring-boot-starter-data-jpa` for JPA, `spring-boot-starter-data-mongodb` for Mongodb, and various other starters for supported technologies.
157
157
To get started, create some repository interfaces to handle your `@Entity` objects.
158
158
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.
161
161
162
162
For more about Spring Data, see the {spring-data}[Spring Data project page].
=== 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:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/using/auto-configuration.adoc
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,3 +35,10 @@ TIP: You can define exclusions both at the annotation level and by using the pro
35
35
36
36
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.
37
37
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