Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
chenpeng_fei
spring-framework
提交
75f47392
S
spring-framework
项目概览
chenpeng_fei
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
75f47392
编写于
9月 24, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
11b4e3be
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
29 deletion
+26
-29
spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java
...rg/springframework/context/annotation/PropertySource.java
+9
-9
spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java
...context/support/PropertySourcesPlaceholderConfigurer.java
+17
-20
未找到文件。
spring-context/src/main/java/org/springframework/context/annotation/PropertySource.java
浏览文件 @
75f47392
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -61,8 +61,8 @@ import java.lang.annotation.Target;
* a {@code PropertySourcesPlaceholderConfigurer}. This happens automatically when using
* {@code <context:property-placeholder>} in XML, but must be explicitly registered using
* a {@code static} {@code @Bean} method when using {@code @Configuration} classes. See
* the "Working with externalized values" section of @{@link Configuration}
J
avadoc and
* "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean}
J
avadoc
* the "Working with externalized values" section of @{@link Configuration}
's j
avadoc and
* "a note on BeanFactoryPostProcessor-returning @Bean methods" of @{@link Bean}
's j
avadoc
* for details and examples.
*
* <h3>Resolving ${...} placeholders within {@code @PropertySource} resource locations</h3>
...
...
@@ -126,11 +126,11 @@ import java.lang.annotation.Target;
* <p>In certain situations, it may not be possible or practical to tightly control
* property source ordering when using {@code @ProperySource} annotations. For example,
* if the {@code @Configuration} classes above were registered via component-scanning,
* the ordering is difficult to predict.
In such cases - and if overriding is important -
* the ordering is difficult to predict. In such cases - and if overriding is important -
* it is recommended that the user fall back to using the programmatic PropertySource API.
* See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment}
* and {@link org.springframework.core.env.MutablePropertySources MutablePropertySources}
*
Javadoc
for details.
*
javadocs
for details.
*
* @author Chris Beams
* @author Phillip Webb
...
...
@@ -160,11 +160,11 @@ public @interface PropertySource {
* Indicate the resource location(s) of the properties file to be loaded.
* For example, {@code "classpath:/com/myco/app.properties"} or
* {@code "file:/path/to/file"}.
* <p>Resource location wildcards (e.g. **/*.properties) are not permitted;
each
* location must evaluate to exactly one {@code .properties} resource.
* <p>Resource location wildcards (e.g. **/*.properties) are not permitted;
*
each
location must evaluate to exactly one {@code .properties} resource.
* <p>${...} placeholders will be resolved against any/all property sources already
* registered with the {@code Environment}. See {@linkplain PropertySource above}
for
* examples.
* registered with the {@code Environment}. See {@linkplain PropertySource above}
*
for
examples.
* <p>Each location will be added to the enclosing {@code Environment} as its own
* property source, and in the order declared.
*/
...
...
spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java
浏览文件 @
75f47392
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -35,26 +35,24 @@ import org.springframework.util.Assert;
import
org.springframework.util.StringValueResolver
;
/**
* Specialization of {@link org.springframework.beans.factory.config.PlaceholderConfigurerSupport
* PlaceholderConfigurerSupport} that resolves ${...} placeholders within bean definition
* property values and {@code @Value} annotations against the current Spring {@link
* Environment} and its set of {@link PropertySources}.
* Specialization of {@link PlaceholderConfigurerSupport} that resolves ${...} placeholders
* within bean definition property values and {@code @Value} annotations against the current
* Spring {@link Environment} and its set of {@link PropertySources}.
*
* <p>This class is designed as a general replacement for {@code
* PropertyPlaceholderConfigurer} in Spring 3.1 applications. It is used by default to
* support the {@code property-placeholder} element in working against the
* spring-context-3.1 XSD, whereas spring-context versions <= 3.0 default to
* {@code PropertyPlaceholderConfigurer} to ensure backward compatibility. See
* spring-context XSD documentation for complete details.
* <p>This class is designed as a general replacement for {@code PropertyPlaceholderConfigurer}
* in Spring 3.1 applications. It is used by default to support the {@code property-placeholder}
* element in working against the spring-context-3.1 XSD, whereas spring-context versions
* <= 3.0 default to {@code PropertyPlaceholderConfigurer} to ensure backward compatibility.
* See the spring-context XSD documentation for complete details.
*
* <p>Any local properties (e.g. those added via {@link #setProperties},
*
{@link #setLocations} et al.) are added as a {@code PropertySource}. Search precedence
*
of local properties is based on the value of the {@link #setLocalOverride localOverride}
*
property, which is by default {@code false} meaning that local properties are to be
*
searched last, after all
environment property sources.
* <p>Any local properties (e.g. those added via {@link #setProperties},
{@link #setLocations}
*
et al.) are added as a {@code PropertySource}. Search precedence of local properties is
*
based on the value of the {@link #setLocalOverride localOverride} property, which is by
*
default {@code false} meaning that local properties are to be searched last, after all
* environment property sources.
*
* <p>See {@link org.springframework.core.env.ConfigurableEnvironment ConfigurableEnvironment}
* and related
Javadoc
for details on manipulating environment property sources.
* and related
javadocs
for details on manipulating environment property sources.
*
* @author Chris Beams
* @since 3.1
...
...
@@ -62,8 +60,7 @@ import org.springframework.util.StringValueResolver;
* @see org.springframework.beans.factory.config.PlaceholderConfigurerSupport
* @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
*/
public
class
PropertySourcesPlaceholderConfigurer
extends
PlaceholderConfigurerSupport
implements
EnvironmentAware
{
public
class
PropertySourcesPlaceholderConfigurer
extends
PlaceholderConfigurerSupport
implements
EnvironmentAware
{
/**
* {@value} is the name given to the {@link PropertySource} for the set of
...
...
@@ -139,7 +136,7 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
}
try
{
PropertySource
<?>
localPropertySource
=
new
PropertiesPropertySource
(
LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME
,
mergeProperties
());
new
PropertiesPropertySource
(
LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME
,
mergeProperties
());
if
(
this
.
localOverride
)
{
this
.
propertySources
.
addFirst
(
localPropertySource
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录