Document auto-configuration packages and how to add to them
Closes gh-27549
This commit is contained in:
@@ -146,7 +146,7 @@ You could take the JPA example from earlier and, assuming that `City` is now a M
|
||||
include::code:CityRepository[]
|
||||
|
||||
Repositories and documents are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and documents by using `@EnableMongoRepositories` and `@EntityScan` respectively.
|
||||
|
||||
TIP: For complete details of Spring Data MongoDB, including its rich object mapping technologies, see its {spring-data-mongodb}[reference documentation].
|
||||
@@ -223,7 +223,7 @@ Spring Boot supports both classic and reactive Neo4j repositories, using the `Ne
|
||||
When Project Reactor is available on the classpath, the reactive style is also auto-configured.
|
||||
|
||||
Repositories and entities are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and entities by using `@EnableNeo4jRepositories` and `@EntityScan` respectively.
|
||||
|
||||
[NOTE]
|
||||
@@ -355,7 +355,7 @@ In fact, both Spring Data JPA and Spring Data Elasticsearch share the same commo
|
||||
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.
|
||||
|
||||
Repositories and documents are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and documents by using `@EnableElasticsearchRepositories` and `@EntityScan` respectively.
|
||||
|
||||
TIP: For complete details of Spring Data Elasticsearch, see the {spring-data-elasticsearch-docs}[reference documentation].
|
||||
@@ -445,7 +445,7 @@ Spring Data includes basic repository support for Cassandra.
|
||||
Currently, this is more limited than the JPA repositories discussed earlier and needs to annotate finder methods with `@Query`.
|
||||
|
||||
Repositories and entities are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and entities by using `@EnableCassandraRepositories` and `@EntityScan` respectively.
|
||||
|
||||
TIP: For complete details of Spring Data Cassandra, see the https://docs.spring.io/spring-data/cassandra/docs/[reference documentation].
|
||||
@@ -500,7 +500,7 @@ To take more control, one or more `ClusterEnvironmentBuilderCustomizer` beans ca
|
||||
Spring Data includes repository support for Couchbase.
|
||||
|
||||
Repositories and documents are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and documents by using `@EnableCouchbaseRepositories` and `@EntityScan` respectively.
|
||||
|
||||
For complete details of Spring Data Couchbase, see the {spring-data-couchbase-docs}[reference documentation].
|
||||
@@ -570,7 +570,7 @@ Make sure to flag your customized `ContextSource` as `@Primary` so that the auto
|
||||
Spring Data includes repository support for LDAP.
|
||||
|
||||
Repositories and documents are found through scanning.
|
||||
By default, the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) and all those below it are searched.
|
||||
By default, the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
You can customize the locations to look for repositories and documents by using `@EnableLdapRepositories` and `@EntityScan` respectively.
|
||||
|
||||
For complete details of Spring Data LDAP, see the https://docs.spring.io/spring-data/ldap/docs/1.0.x/reference/html/[reference documentation].
|
||||
|
||||
@@ -195,7 +195,7 @@ You can follow the https://spring.io/guides/gs/accessing-data-jpa/["`Accessing D
|
||||
==== Entity Classes
|
||||
Traditionally, JPA "`Entity`" classes are specified in a `persistence.xml` file.
|
||||
With Spring Boot, this file is not necessary and "`Entity Scanning`" is used instead.
|
||||
By default, all packages below your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) are searched.
|
||||
By default the <<using#using.auto-configuration.packages,auto-configuration packages>> are scanned.
|
||||
|
||||
Any classes annotated with `@Entity`, `@Embeddable`, or `@MappedSuperclass` are considered.
|
||||
A typical entity class resembles the following example:
|
||||
@@ -216,7 +216,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
|
||||
For more complex queries, you can annotate your method with Spring Data's {spring-data-jpa-api}/repository/Query.html[`Query`] annotation.
|
||||
|
||||
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.
|
||||
If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) down.
|
||||
If you use auto-configuration, the <<using#using.auto-configuration.packages,auto-configuration packages>> are searched for repositories.
|
||||
|
||||
TIP: You can customize the locations to look for repositories using `@EnableJpaRepositories`.
|
||||
|
||||
@@ -506,7 +506,7 @@ For example, a `CityRepository` interface might declare a `findAllByState(String
|
||||
For more complex queries, you can annotate your method with Spring Data's {spring-data-r2dbc-api}/repository/Query.html[`Query`] annotation.
|
||||
|
||||
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.
|
||||
If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with `@EnableAutoConfiguration` or `@SpringBootApplication`) down.
|
||||
If you use auto-configuration, the <<using#using.auto-configuration.packages,auto-configuration packages>> are searched for repositories.
|
||||
|
||||
The following example shows a typical Spring Data repository interface definition:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user