0

我正在尝试使用 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

4

1 回答 1

0

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

<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  <property name="locations" value="file:/etc/app/*.prop"/>
</bean>
于 2017-08-19T09:08:59.997 回答