简体   繁体   English

无法在Spring的应用程序上下文中加载多个属性文件

[英]Can't load multiple property files in spring's application context

I have three property files placed in a resource folder in classpath. 我在类路径的资源文件夹中放置了三个属性文件。 The problem i am facing is while i am able to load invidual files separately i am unable to load them when they are declared together. 我面临的问题是,当我能够分别加载单个文件时,当它们一起声明时,我无法加载它们。

Please see the XML below: 请参见下面的XML:

<bean name="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames"    value="resources\label"/>

</bean>
                                                                                                                                                                          This is working but the XML given below isn't:                                             
<bean name="messageSource"
        class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames"    value="resources\label,resources\button,resources\messages"/>
    <property name="cacheSeconds" value="1"/>
</bean>

I wish to declared them together as I wish to use a single bean to access all three files. 我希望将它们一起声明,因为我希望使用一个bean来访问所有三个文件。 Help required! 需要帮助!

Found the answer . 找到了答案。 It should be like this 应该是这样
` `

          <property name="basenames">
          <list>
               <value>classpath:resources\label</value>
               <value>classpath:resources\button</value>
               <value>classpath:resources\messages</value>
          </list>
          </property>

       </bean>

Do it like this 像这样做

<property name="basenames">
    <list>
        <value>resources\label</value>
        <value>resources\button</value>
        <value>resources\messages</value>
    </list>
</property>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM