如何在Spring中使用Apache Commons PropertiesConfiguration作为MessageSource?

时间:2018-05-08 20:03:05

标签: java spring properties-file spring-4 apache-commons-config

我目前使用Spring ReloadableResourceBundleMessageSource作为MessageSource来阅读国际化消息。

我使用的Spring版本是: 4.3.1.RELEASE

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>classpath:messages/messages</value>
        </list>
    </property>
    <property name="cacheSeconds" value="1" />
    <property name="defaultEncoding" value="UTF-8" />
</bean>

问题是我想将PropertiesConfiguration (from Apache Commons Configuration 2)用作MessageSource。我遇到的问题是两者都扩展了不同的类。我需要知道Apache Commons Configuration是否提供了现成的MessageSource PropertiesConfiguration或者如何使用此配置创建新的MessageSource

使用此配置的好处是拥有Variable Interpolation类中不可用的Properties

我的问题基于this question,但有一点麻烦,因为我不直接在我的应用中使用属性,而是通过Spring提供的消息源,我不想更改该代码。< / p>

0 个答案:

没有答案