Skip to content

Commit 8aadb8d

Browse files
committed
Polish Javadoc
Issue: SPR-14552
1 parent e86529e commit 8aadb8d

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

spring-context/src/main/java/org/springframework/context/annotation/Configuration.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,22 @@
8484
* {@code @Configuration} classes are candidates for component scanning (typically using
8585
* Spring XML's {@code <context:component-scan/>} element) and therefore may also take
8686
* advantage of {@link Autowired @Autowired}/{@link javax.inject.Inject @Inject}
87-
* at the field and method level (but not at the constructor level).
87+
* like any regular {@code @Component}. In particular, if a single constructor is present
88+
* autowiring semantics will be applied transparently:
89+
*
90+
* <pre class="code">
91+
* &#064;Configuration
92+
* public class AppConfig {
93+
* private final SomeBean someBean;
94+
*
95+
* public AppConfig(SomeBean someBean) {
96+
* this.someBean = someBean;
97+
* }
98+
*
99+
* // &#064;Bean definition using "SomeBean"
100+
*
101+
* }</pre>
102+
*
88103
* <p>{@code @Configuration} classes may not only be bootstrapped using
89104
* component scanning, but may also themselves <em>configure</em> component scanning using
90105
* the {@link ComponentScan @ComponentScan} annotation:
@@ -104,13 +119,13 @@
104119
*
105120
* Externalized values may be looked up by injecting the Spring
106121
* {@link org.springframework.core.env.Environment} into a {@code @Configuration}
107-
* class using the {@code @Autowired} or the {@code @Inject} annotation:
122+
* class the usual (e.g. using the {@code @Autowired} annotation):
108123
*
109124
* <pre class="code">
110125
* &#064;Configuration
111126
* public class AppConfig {
112127
*
113-
* &#064Inject Environment env;
128+
* &#064Autowired Environment env;
114129
*
115130
* &#064;Bean
116131
* public MyBean myBean() {
@@ -175,7 +190,7 @@
175190
* <p>{@code @Configuration} classes may be composed using the {@link Import @Import} annotation,
176191
* not unlike the way that {@code <import>} works in Spring XML. Because
177192
* {@code @Configuration} objects are managed as Spring beans within the container,
178-
* imported configurations may be injected using {@code @Autowired} or {@code @Inject}:
193+
* imported configurations may be injected the usual way (e.g. via constructor injection):
179194
*
180195
* <pre class="code">
181196
* &#064;Configuration
@@ -191,7 +206,11 @@
191206
* &#064;Import(DatabaseConfig.class)
192207
* public class AppConfig {
193208
*
194-
* &#064Inject DatabaseConfig dataConfig;
209+
* private final DatabaseConfig dataConfig;
210+
*
211+
* public AppConfig(DatabaseConfig dataConfig) {
212+
* this.dataConfig = dataConfig;
213+
* }
195214
*
196215
* &#064;Bean
197216
* public MyBean myBean() {
@@ -240,8 +259,8 @@
240259
* As mentioned above, {@code @Configuration} classes may be declared as regular Spring
241260
* {@code <bean>} definitions within Spring XML files. It is also possible to
242261
* import Spring XML configuration files into {@code @Configuration} classes using
243-
* the {@link ImportResource @ImportResource} annotation. Bean definitions imported from XML can be
244-
* injected using {@code @Autowired} or {@code @Inject}:
262+
* the {@link ImportResource @ImportResource} annotation. Bean definitions imported from
263+
* XML can be injected the usual way (e.g. using the {@code Inject} annotation):
245264
*
246265
* <pre class="code">
247266
* &#064;Configuration
@@ -340,9 +359,7 @@
340359
* <ul>
341360
* <li>&#064;Configuration classes must be non-final
342361
* <li>&#064;Configuration classes must be non-local (may not be declared within a method)
343-
* <li>&#064;Configuration classes must have a default/no-arg constructor and may not use
344-
* {@link Autowired @Autowired} constructor parameters. Any nested configuration classes
345-
* must be {@code static}.
362+
* <li>Any nested configuration classes must be {@code static}.
346363
* </ul>
347364
*
348365
* @author Rod Johnson

0 commit comments

Comments
 (0)