Spring 使用多个属性文件从PropertyPlaceHolderConfigure访问属性

Spring 使用多个属性文件从PropertyPlaceHolderConfigure访问属性,spring,dependency-injection,Spring,Dependency Injection,我刚接触spring(3.1),完全被这个问题难住了。 我试图使用在两个属性文件(一个覆盖另一个)中定义的PropertyPlaceHolderConfigure访问属性值“schdestination” 我想用@Value在一个类中设置一个字段,但如果不使用另一个bean,我就找不到一个方法。下面是我的SpringXML片段 <bean id="placeholderProperties" class="org.springframework.beans.factory.config.P

我刚接触spring(3.1),完全被这个问题难住了。 我试图使用在两个属性文件(一个覆盖另一个)中定义的PropertyPlaceHolderConfigure访问属性值“schdestination”

我想用@Value在一个类中设置一个字段,但如果不使用另一个bean,我就找不到一个方法。下面是我的SpringXML片段

<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>/WEB-INF/abc.properties</value>
            <value>/WEB-INF/loc.abc.properties</value>
        </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="order" value="1" />
</bean>

/WEB-INF/abc.properties
/WEB-INF/loc.abc.properties
有什么线索吗

@Value("${schdestination}")
private String destination;

应该可以工作。

包含
@值的类需要使用
@组件进行注释,并且您的应用程序context.xml中需要有

您是否在web应用程序中使用它?这就是我的情况。我从应用程序上下文加载属性文件,但不知何故,它们在web应用程序包中是不可见的,确切地说是控制器。我必须在servlet-context.xml中重新声明它们,然后它们就可以看到并且工作正常。我真的希望有人能解释一下可能发生的事情,或者这是否真的是一个需要在春季解决的问题。

这就是我正在尝试的,但不知怎的,字符串值回来了:变量destination的值为“${schdestination}”,而不是属性文件的路径。在哪个xml文件中定义了配置器?