Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
bf6653b8
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,体验更适合开发者的 AI 搜索 >>
提交
bf6653b8
编写于
9月 18, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapted to 4.3.3 backport
Issue: SPR-14728
上级
f532de92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
14 deletion
+16
-14
spring-context/src/main/java/org/springframework/context/annotation/Bean.java
...ain/java/org/springframework/context/annotation/Bean.java
+12
-12
spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java
...tion/configuration/ConfigurationClassProcessingTests.java
+4
-2
未找到文件。
spring-context/src/main/java/org/springframework/context/annotation/Bean.java
浏览文件 @
bf6653b8
...
...
@@ -46,14 +46,14 @@ import org.springframework.core.annotation.AliasFor;
* <h3>Bean Names</h3>
*
* <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 {@code @Bean} method.
This
*
is convenient and intuitive, but if explicit naming is desired, the {@code name}
*
attribute (or its alias {@code value}) may be used. Also note that {@code name}
*
accepts an array of Strings. This is in order to allow for specifying
multiple names
* (i.e.
,
aliases) for a single bean.
* determining the name of a bean is to use the name of the {@code @Bean} method.
*
This is convenient and intuitive, but if explicit naming is desired, the
*
{@code name} attribute (or its alias {@code value}) may be used. Also note
*
that {@code name} accepts an array of Strings, allowing for
multiple names
* (i.e.
a primary bean name plus one or more
aliases) for a single bean.
*
* <pre class="code">
* @Bean({"b1","b2"}) // bean available as 'b1' and 'b2', but not 'myBean'
* @Bean({"b1",
"b2"}) // bean available as 'b1' and 'b2', but not 'myBean'
* public MyBean myBean() {
* // instantiate and configure MyBean obj
* return obj;
...
...
@@ -79,9 +79,9 @@ import org.springframework.core.annotation.AliasFor;
* <h3>{@code @Bean} Methods in {@code @Configuration} Classes</h3>
*
* <p>Typically, {@code @Bean} methods are declared within {@code @Configuration}
* classes. In this case, bean methods may reference other {@code @Bean} methods
*
in the same class by calling them <i>directly</i>. This ensures that references between
*
beans
are strongly typed and navigable. Such so-called <em>'inter-bean references'</em> are
* classes. In this case, bean methods may reference other {@code @Bean} methods
in the
*
same class by calling them <i>directly</i>. This ensures that references between beans
* are strongly typed and navigable. Such so-called <em>'inter-bean references'</em> are
* guaranteed to respect scoping and AOP semantics, just like {@code getBean()} 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
...
...
@@ -194,15 +194,15 @@ public @interface Bean {
* Alias for {@link #name}.
* <p>Intended to be used when no other attributes are needed, for example:
* {@code @Bean("customBeanName")}.
* @since
5.0
* @since
4.3.3
* @see #name
*/
@AliasFor
(
"name"
)
String
[]
value
()
default
{};
/**
* The name of this bean, or if
plural, aliases for this bean
.
* <p>If left unspecified the name of the bean is the name of the annotated method.
* The name of this bean, or if
several names, a primary bean name plus aliases
.
* <p>If left unspecified
,
the name of the bean is the name of the annotated method.
* If specified, the method name is ignored.
* <p>The bean name and aliases may also be configured via the {@link #value}
* attribute if no other attributes are declared.
...
...
spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java
浏览文件 @
bf6653b8
...
...
@@ -21,7 +21,6 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.Set
;
import
java.util.function.Supplier
;
import
javax.inject.Provider
;
import
org.junit.Rule
;
...
...
@@ -279,6 +278,7 @@ public class ConfigurationClassProcessingTests {
}
}
@Configuration
static
class
ConfigWithBeanWithCustomNameConfiguredViaValueAttribute
{
...
...
@@ -290,6 +290,7 @@ public class ConfigurationClassProcessingTests {
}
}
@Configuration
static
class
ConfigWithBeanWithAliases
{
...
...
@@ -301,6 +302,7 @@ public class ConfigurationClassProcessingTests {
}
}
@Configuration
static
class
ConfigWithBeanWithAliasesConfiguredViaValueAttribute
{
...
...
@@ -452,7 +454,7 @@ public class ConfigurationClassProcessingTests {
};
}
//@Bean
//
@Bean
public
BeanFactoryPostProcessor
beanFactoryPostProcessor
()
{
return
new
BeanFactoryPostProcessor
()
{
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录