Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
3cfac84b
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3cfac84b
编写于
12月 13, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated javadoc (SPR-6546)
上级
1b8a67d5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
22 deletion
+26
-22
org.springframework.context/src/main/java/org/springframework/context/annotation/Bean.java
...ain/java/org/springframework/context/annotation/Bean.java
+26
-22
未找到文件。
org.springframework.context/src/main/java/org/springframework/context/annotation/Bean.java
浏览文件 @
3cfac84b
...
@@ -27,46 +27,50 @@ import org.springframework.beans.factory.annotation.Autowire;
...
@@ -27,46 +27,50 @@ import org.springframework.beans.factory.annotation.Autowire;
/**
/**
* Indicates that a method produces a bean to be managed by the Spring container. The
* 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
* names and semantics of the attributes to this annotation are intentionally similar
* to those of the {@literal <bean/>} element in the Spring XML schema. Deviations are
* to those of the {@literal <bean/>} element in the Spring XML schema.
* as follows:
*
*
* <p>The Bean annotation does not provide attributes for scope, primary or lazy. Rather,
* <p>Note that the <code>@Bean</code> annotation does not provide attributes for scope,
* it should be used in conjunction with {@link Scope @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 the
* {@link Primary @Primary}, and {@link Lazy @Lazy} annotations to achieve
* same semantics.
* those semantics. The same annotations can also be used at the type level, e.g. for
* component scanning.
*
*
* <p>While a {@link #name()} attribute is available, the default strategy for determining
* <p>While a {@link #name()} attribute is available, the default strategy for determining
* the name of a bean is to use the name of the Bean method. This is convenient and
* the name of a bean is to use the name of the Bean method. This is convenient and
* intuitive, but if explicit naming is desired, the {@link #name()} attribute may be used.
* intuitive, but if explicit naming is desired, the {@link #name()} attribute may be used.
* Also note that {@link #name()} accepts an array of
s
trings. This is in order to allow
* Also note that {@link #name()} accepts an array of
S
trings. This is in order to allow
* for specifying multiple names (i.e., aliases) for a single bean.
* for specifying multiple names (i.e., aliases) for a single bean.
*
*
* <h3>Constraints</h3>
* <p>The <code>@Bean</code> annotation may be used on any methods in an <code>@Component</code>
* <ul>
* class, in which case they will get processed in a configuration class 'lite' mode where
* <li>Bean methods are valid only when declared within an {@link Configuration @Configuration}-annotated class
* they will simply be called as plain factory methods from the container (similar to
* <li>Bean methods must be non-void, non-final, non-private
* <code>factory-method</code> declarations in XML). The containing component classes remain
* <li>Bean methods may not accept any arguments
* unmodified in this case, and there are no unusual constraints for factory methods.
* <li>Bean methods may throw any exception, which will be caught and handled
* by the Spring container on processing of the declaring {@link Configuration @Configuration} class.
* </ul>
*
*
* <h3>Usage</h3>
* <p>As an advanced mode, <code>@Bean</code> may also be used within <code>@Configuration</code>
* <p>Bean methods may reference other Bean methods by calling them directly. This ensures
* component classes. In this case, bean methods may reference other <code>@Bean</code> methods
* that references between beans are strongly typed and navigable. So called 'inter-bean
* on the same class by calling them <i>directly</i>. This ensures that references between beans
* references' are guaranteed to respect scoping and AOP semantics.
* are strongly typed and navigable. Such so-called 'inter-bean references' are guaranteed to
* respect scoping and AOP semantics, just like <code>getBean</code> lookups would. These are
* the semantics known from the original 'Spring JavaConfig' project which require CGLIB
* subclassing of each such configuration class at runtime. As a consequence, configuration
* classes and their factory methods must not be marked as final or private in this mode.
*
*
* @author Rod Johnson
* @author Rod Johnson
* @author Costin Leau
* @author Costin Leau
* @author Chris Beams
* @author Chris Beams
* @author Juergen Hoeller
* @since 3.0
* @since 3.0
* @see org.springframework.stereotype.Component
* @see Configuration
* @see Configuration
* @see Scope
* @see DependsOn
* @see DependsOn
* @see Lazy
* @see Lazy
* @see Primary
* @see Primary
* @see
Scope
* @see
org.springframework.beans.factory.annotation.Autowired
* @see Value
* @see
org.springframework.beans.factory.annotation.
Value
*/
*/
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
ANNOTATION_TYPE
})
@Target
(
{
ElementType
.
METHOD
,
ElementType
.
ANNOTATION_TYPE
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
@Documented
public
@interface
Bean
{
public
@interface
Bean
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录