Skip to content

Commit 1fc3fc8

Browse files
committed
Update documentation
Issue: SPR-13471
1 parent edd8e2d commit 1fc3fc8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/asciidoc/core-beans.adoc

+13-1
Original file line numberDiff line numberDiff line change
@@ -6788,8 +6788,12 @@ work on the configuration class itself since it is being created as a bean insta
67886788
@Configuration
67896789
public class RepositoryConfig {
67906790
6791+
private final DataSource dataSource;
6792+
67916793
@Autowired
6792-
private DataSource dataSource;
6794+
public RepositoryConfig(DataSource dataSource) {
6795+
this.dataSource = dataSource;
6796+
}
67936797
67946798
@Bean
67956799
public AccountRepository accountRepository() {
@@ -6817,6 +6821,14 @@ work on the configuration class itself since it is being created as a bean insta
68176821
}
68186822
----
68196823

6824+
[TIP]
6825+
====
6826+
Constructor injection in `@Configuration` classes is only supported as of Spring
6827+
Framework 4.3. Note also that there is no need to specify `@Autowired` if the target
6828+
bean defines only one constructor; in the example above, `@Autowired` is not necessary
6829+
on the `RepositoryConfig` constructor.
6830+
====
6831+
68206832
.[[beans-java-injecting-imported-beans-fq]]Fully-qualifying imported beans for ease of navigation
68216833
--
68226834
In the scenario above, using `@Autowired` works well and provides the desired

src/asciidoc/whats-new.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ public @interface MyTestConfig {
631631

632632
* It is no longer necessary to specify the `@Autowired` annotation if the target
633633
bean only define one constructor.
634+
* `@Configuration` classes support constructor injection.
634635

635636

636637
=== Testing Improvements

0 commit comments

Comments
 (0)