【问题标题】:Spring PropertiesFactoryBean wildcard expansion not workingSpring PropertiesFactoryBean 通配符扩展不起作用
【发布时间】:2018-01-21 01:51:57
【问题描述】:

我正在尝试使用 PropertiesFactoryBean 从某个目录加载所有以.prop结尾的文件。

<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="location" value="file:/etc/app/*.prop"/>
</bean>

将其作为 Junit 测试运行时,一切正常,org.springframework.core.io.support.PropertiesLoaderSupport#loadProperties 获取所有文件列表(通配符扩展)为FileSystemResource 并加载它们。

但是,当在 OSGI 环境 (Karaf) 中运行时,PropertiesLoaderSupport#loadProperties 将获得单个 OsgiBundleResource,路径设置为 /etc/app/*.prop,当然这是无效的。

【问题讨论】:

    标签: java spring apache-karaf spring-dm spring-properties


    【解决方案1】:

    尝试使用locations 属性而不是location(它只支持一种资源)

    <bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
      <property name="locations" value="file:/etc/app/*.prop"/>
    </bean>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      相关资源
      最近更新 更多