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 5c0fcd6805..8cbaa0da3b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition; * public MyBean myBean() { * // instantiate and configure MyBean obj * return obj; - * } + * } + * * *
* @Configuration
* public class AppConfig {
+ *
* @Bean
* public FooService fooService() {
* return new FooService(fooRepository());
* }
+ *
* @Bean
* public FooRepository fooRepository() {
* return new JdbcFooRepository(dataSource());
* }
+ *
* // ...
* }
*
@@ -152,7 +158,8 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
* @Bean
* public static PropertyPlaceholderConfigurer ppc() {
* // instantiate, configure and return ppc ...
- * }
+ * }
+ *
*
* By marking this method as {@code static}, it can be invoked without causing instantiation of its
* declaring {@code @Configuration} class, thus avoiding the above-mentioned lifecycle conflicts.
@@ -191,6 +198,13 @@ public @interface Bean {
/**
* Are dependencies to be injected via convention-based autowiring by name or type?
+ * Note that this autowire mode is just about externally driven autowiring based + * on bean property setter methods by convention, analogous to XML bean definitions. + *
The default mode does allow for annotation-driven autowiring. "no" refers to + * externally driven autowiring only, not affecting any autowiring demands that the + * bean class itself expresses through annotations. + * @see Autowire#BY_NAME + * @see Autowire#BY_TYPE */ Autowire autowire() default Autowire.NO;