1
2
3
4
5
6
7
8
9
10
|
<
bean
id
=
"configProperties"
class
=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>
<
property
name
=
"locations"
>
<
list
>
<
value
>classpath*:META-INF/spring/*.properties</
value
>
</
list
>
</
property
>
</
bean
>
<
bean
id
=
"propertyConfigurer"
class
=
"org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"
>
<
property
name
=
"properties"
ref
=
"configProperties"
/>
</
bean
>
|
1
2
3
4
5
6
7
|
import
org.springframework.beans.factory.annotation.Value;
@Value
(
"#{configProperties['test.value']}"
)
private
String testValue;
System.out.println(
"TestValue Is: "
+ testValue);
// 输出结果 Test Value Is: iloveyou
出处:http://xitongjiagoushi.blog.51cto.com/9975742/1659051
|