Spring PropertiesFactoryBean wildcard expansion not working

570 Views Asked by At

I'm trying to use PropertiesFactoryBean to load all files ending with .propfrom certain directory.

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

When running this as Junit test, everyting works OK and org.springframework.core.io.support.PropertiesLoaderSupport#loadProperties get list of all files (wildcard expanded) as FileSystemResource and loads them.

However when running in OSGI environment (Karaf) PropertiesLoaderSupport#loadProperties will get single OsgiBundleResource with path set to /etc/app/*.prop which is invalid, of course.

1

There are 1 best solutions below

0
Jérémie B On

Try to use the locations property instead of location (which supports only one resource)

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