|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2016 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
39 | 39 | * public MyBean myBean() {
|
40 | 40 | * // instantiate and configure MyBean obj
|
41 | 41 | * return obj;
|
42 |
| - * }</pre> |
| 42 | + * } |
| 43 | + * </pre> |
43 | 44 | *
|
44 | 45 | * <h3>Bean Names</h3>
|
45 | 46 | *
|
|
55 | 56 | * public MyBean myBean() {
|
56 | 57 | * // instantiate and configure MyBean obj
|
57 | 58 | * return obj;
|
58 |
| - * }</pre> |
| 59 | + * } |
| 60 | + * </pre> |
59 | 61 | *
|
60 | 62 | * <h3>Scope, DependsOn, Primary, and Lazy</h3>
|
61 | 63 | *
|
|
70 | 72 | * public MyBean myBean() {
|
71 | 73 | * // instantiate and configure MyBean obj
|
72 | 74 | * return obj;
|
73 |
| - * }</pre> |
| 75 | + * } |
| 76 | + * </pre> |
74 | 77 | *
|
75 | 78 | * <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3>
|
76 | 79 | *
|
|
87 | 90 | * <pre class="code">
|
88 | 91 | * @Configuration
|
89 | 92 | * public class AppConfig {
|
| 93 | + * |
90 | 94 | * @Bean
|
91 | 95 | * public FooService fooService() {
|
92 | 96 | * return new FooService(fooRepository());
|
93 | 97 | * }
|
| 98 | + * |
94 | 99 | * @Bean
|
95 | 100 | * public FooRepository fooRepository() {
|
96 | 101 | * return new JdbcFooRepository(dataSource());
|
97 | 102 | * }
|
| 103 | + * |
98 | 104 | * // ...
|
99 | 105 | * }</pre>
|
100 | 106 | *
|
|
152 | 158 | * @Bean
|
153 | 159 | * public static PropertyPlaceholderConfigurer ppc() {
|
154 | 160 | * // instantiate, configure and return ppc ...
|
155 |
| - * }</pre> |
| 161 | + * } |
| 162 | + * </pre> |
156 | 163 | *
|
157 | 164 | * By marking this method as {@code static}, it can be invoked without causing instantiation of its
|
158 | 165 | * declaring {@code @Configuration} class, thus avoiding the above-mentioned lifecycle conflicts.
|
|
191 | 198 |
|
192 | 199 | /**
|
193 | 200 | * 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 |
194 | 208 | */
|
195 | 209 | Autowire autowire() default Autowire.NO;
|
196 | 210 |
|
|
0 commit comments