上下文:财产持有人。 PropertyPlaceholderConfigurer

时间:2012-11-21 09:24:19

标签: spring

在以下两种情况下如何使用@Value?

案例1:我有一个PropertyPlaceholderConfigurer bean定义如下

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <value>file:#{ systemProperties['user.home']}/myconf/settings.properties</value>
    </property>
</bean>

案例2:我没有定义bean,但我在上下文中声明了property-place holder,如下所示

<context:property-placeholder 
     location="file:#{ systemProperties['user.home']}/myconf/settings.properties"  />

1 个答案:

答案 0 :(得分:0)

在这两种情况下,您都会使用

@Value(value="${key.in.file}")
private String myVar;
相关问题