【问题标题】:Spring how to load multiple property files in one beanSpring如何在一个bean中加载多个属性文件
【发布时间】:2016-07-20 10:20:41
【问题描述】:

我有一个加载属性文件的 applicationContext 和一个作为资源注入的 bean。这可以正常工作。

<bean id="testSettings" class="com.icat.di.testing.framework.TestSettings" scope="singleton"/>
<util:properties id="testProperties" location="classpath:${test.properties}" />

我想添加第二个属性文件。我读过不允许多个&lt;util:properties 条目。

我尝试了添加属性列表的旧方法:

<bean id="testSettings" class="testing.framework.TestSettings">
    <property name="testProperties">
        <list>
            <value>classpath:test.properties</value>
        </list>
    </property>
    <property name="configProperties">
        <list>
            <value>classpath:config.properties</value>
        </list>
    </property>
</bean>

我在我的 TestSettings 类中添加了 configProperties 作为资源。这无法加载应用程序上下文。

如何在 Spring 4 中加载两个属性文件?

【问题讨论】:

标签: java spring


【解决方案1】:

尝试在你的 bean 中添加这个属性:

    <property name="ignoreUnresolvablePlaceholders" value="true"/>

【讨论】:

    猜你喜欢
    • 2019-03-30
    • 1970-01-01
    • 2012-02-29
    • 2016-06-18
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2012-04-28
    相关资源
    最近更新 更多