跨Web应用程序共享ResourceBundle

时间:2017-11-30 07:12:30

标签: spring spring-mvc localization resourcebundle

是否可以从一个弹簧Web应用程序访问消息资源到另一个弹簧Web应用程序?

1 个答案:

答案 0 :(得分:0)

我们在将属性文件作为电子邮件设置加载时遇到类似情况。我们通过指定完整的文件路径将文件放在2个应用程序中引用它的公共位置来完成它。

<bean id="mailProperties"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

    <property name="location" value="file:/share/mail/config/mail.properties" />

</bean>

我认为,您可以采用与以下类似的方式进行此操作

<beans:bean id="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <beans:property name="basename" value="file:/common_place_for_/messages" />
        <beans:property name="defaultEncoding" value="UTF-8" />
    </beans:bean>