Skip to content

Commit 7da1295

Browse files
committed
@bean's "autowire" attribute does not affect annotation-driven autowiring
Issue: SPR-14282 (cherry picked from commit 98eaf05)
1 parent 6009e03 commit 7da1295

File tree

1 file changed

+19
-5
lines changed
  • spring-context/src/main/java/org/springframework/context/annotation

1 file changed

+19
-5
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,8 @@
3939
* public MyBean myBean() {
4040
* // instantiate and configure MyBean obj
4141
* return obj;
42-
* }</pre>
42+
* }
43+
* </pre>
4344
*
4445
* <h3>Bean Names</h3>
4546
*
@@ -55,7 +56,8 @@
5556
* public MyBean myBean() {
5657
* // instantiate and configure MyBean obj
5758
* return obj;
58-
* }</pre>
59+
* }
60+
* </pre>
5961
*
6062
* <h3>Scope, DependsOn, Primary, and Lazy</h3>
6163
*
@@ -70,7 +72,8 @@
7072
* public MyBean myBean() {
7173
* // instantiate and configure MyBean obj
7274
* return obj;
73-
* }</pre>
75+
* }
76+
* </pre>
7477
*
7578
* <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3>
7679
*
@@ -87,14 +90,17 @@
8790
* <pre class="code">
8891
* &#064;Configuration
8992
* public class AppConfig {
93+
*
9094
* &#064;Bean
9195
* public FooService fooService() {
9296
* return new FooService(fooRepository());
9397
* }
98+
*
9499
* &#064;Bean
95100
* public FooRepository fooRepository() {
96101
* return new JdbcFooRepository(dataSource());
97102
* }
103+
*
98104
* // ...
99105
* }</pre>
100106
*
@@ -152,7 +158,8 @@
152158
* &#064;Bean
153159
* public static PropertyPlaceholderConfigurer ppc() {
154160
* // instantiate, configure and return ppc ...
155-
* }</pre>
161+
* }
162+
* </pre>
156163
*
157164
* By marking this method as {@code static}, it can be invoked without causing instantiation of its
158165
* declaring {@code @Configuration} class, thus avoiding the above-mentioned lifecycle conflicts.
@@ -191,6 +198,13 @@
191198

192199
/**
193200
* Are dependencies to be injected via convention-based autowiring by name or type?
201+
* <p>Note that this autowire mode is just about externally driven autowiring based
202+
* on bean property setter methods by convention, analogous to XML bean definitions.
203+
* <p>The default mode does allow for annotation-driven autowiring. "no" refers to
204+
* externally driven autowiring only, not affecting any autowiring demands that the
205+
* bean class itself expresses through annotations.
206+
* @see Autowire#BY_NAME
207+
* @see Autowire#BY_TYPE
194208
*/
195209
Autowire autowire() default Autowire.NO;
196210

0 commit comments

Comments
 (0)