diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java index 15b3a394b0..06f74784cf 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Bean.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Bean.java @@ -28,6 +28,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; /** * Indicates that a method produces a bean to be managed by the Spring container. * + *
The names and semantics of the attributes to this annotation are intentionally
* similar to those of the {@code
Note that the {@code @Bean} annotation does not provide attributes for scope, - * primary, or lazy. Rather, it should be used in conjunction with {@link Scope @Scope}, - * {@link Primary @Primary}, and {@link Lazy @Lazy} annotations to achieve those - * semantics. For example: + * depends-on, primary, or lazy. Rather, it should be used in conjunction with + * {@link Scope @Scope}, {@link DependsOn @DependsOn}, {@link Primary @Primary}, + * and {@link Lazy @Lazy} annotations to achieve those semantics. For example: * *
* @Bean @@ -96,15 +98,21 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; * // ... * }* - *
{@code @Bean} methods may also be declared within any {@code @Component} class, in - * which case they will get processed in a configuration class 'lite' mode in which - * they will simply be called as plain factory methods from the container (similar to - * {@code factory-method} declarations in XML) but with prototype semantics. - * The containing component classes remain unmodified in this case, and there are no - * unusual constraints for factory methods; however, scoping semantics are not - * respected as described above for inter-bean method invocations in this mode. For example: + *
{@code @Bean} methods may also be declared within classes that are not + * annotated with {@code @Configuration}. For example, bean methods may be declared + * in a {@code @Component} class or even in a plain old class. In such cases, + * a {@code @Bean} method will get processed in a configuration class 'lite' + * mode. + * + *
In contrast to bean methods in {@code @Configuration} classes as described + * above, bean methods in lite mode will be called as plain factory + * methods from the container (similar to {@code factory-method} declarations + * in XML) but with prototype semantics. The containing class remains + * unmodified in this case, and there are no unusual constraints for factory methods; + * however, scoping semantics are not respected as described above for + * 'inter-bean method invocations in this mode. For example: * *
* @Component
@@ -214,4 +222,4 @@ public @interface Bean {
*/
String destroyMethod() default AbstractBeanDefinition.INFER_METHOD;
-}
+}
\ No newline at end of file