多个Spring配置文件用于xml属性文件?

时间:2017-01-23 15:02:56

标签: spring spring-profiles

我想根据属性将多个配置文件提供到 -

    <beans:property name="locations">
        <beans:list>
            <beans:value>classpath:properties/local.properties</beans:value>
            <beans:value>classpath:properties/${spring.profiles.active}.properties</beans:value>
        </beans:list>
    </beans:property>

在我可以使用的印象中 -

  <context-param>
    <param-name>spring.profiles.active</param-name>
    <param-value>profile-a, profile-b</param-value>
  </context-param>

我收到此错误 - 所以它没有解析param-values -

14:13:12.065 [localhost-startStop-1] TRACE o.s.c.e.PropertySourcesPropertyResolver - getProperty("spring.profiles.active", String)
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletConfigInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in [servletContextInitParams] with type [String] and value profile-a, profile-b'
14:13:12.065 [localhost-startStop-1] TRACE o.s.util.PropertyPlaceholderHelper - Resolved placeholder 'spring.profiles.active'
14:13:12.065 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'dsProperties'
14:13:12.065 [localhost-startStop-1] INFO  o.s.b.f.config.PropertiesFactoryBean - Loading properties file from class path resource [properties/profile-a, profile-b.properties]
14:13:12.065 [localhost-startStop-1] WARN  o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [properties/ profile-a, profile-b.properties.properties]: class path

可以这样做吗?

0 个答案:

没有答案