Skip to content

Commit c9e548b

Browse files
committed
Link to Framework's docs about @bean's autowiring exclusion
Closes gh-42586
1 parent 0350eb8 commit c9e548b

File tree

1 file changed

+5
-0
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages

1 file changed

+5
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/data-access.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ See xref:reference:data/sql.adoc#data.sql.datasource[] in the "`Spring Boot Feat
113113
To define an additional `DataSource`, an approach that's similar to the previous section can be used.
114114
A key difference is that the `DataSource` `@Bean` must be declared with `defaultCandidate=false`.
115115
This prevents the auto-configured `DataSource` from backing off.
116+
117+
NOTE: The {url-spring-framework-docs}/core/beans/dependencies/factory-autowire.html#beans-factory-autowire-candidate[Spring Framework reference documentation] describes this feature in more details.
118+
116119
To allow the additional `DataSource` to be injected where it's needed, also annotate it with `@Qualifier` as shown in the following example:
117120

118121
include-code::MyAdditionalDataSourceConfiguration[]
@@ -314,6 +317,8 @@ It scans entities located in the same package as `Order`.
314317
It is possible to map additional JPA properties using the `app.jpa` namespace.
315318
The use of `@Bean(defaultCandidate=false)` allows the `secondJpaProperties` and `secondEntityManagerFactory` beans to be defined without interfering with auto-configured beans of the same type.
316319

320+
NOTE: The {url-spring-framework-docs}/core/beans/dependencies/factory-autowire.html#beans-factory-autowire-candidate[Spring Framework reference documentation] describes this feature in more details.
321+
317322
You should provide a similar configuration for any more additional data sources for which you need JPA access.
318323
To complete the picture, you need to configure a `JpaTransactionManager` for each `EntityManagerFactory` as well.
319324
Alternatively, you might be able to use a JTA transaction manager that spans both.

0 commit comments

Comments
 (0)