В Spring 4.x я всегда использовал file:#{systemProperties['user.home']}
для доступа к локальному файлу и загрузки переменных конфигурации. Но для очень старого проекта мы должны использовать Spring 1.x (1.2.7), и тот же код теперь не работает. Я также пробовал с file:${systemProperties['user.home']}
, но ничего. Мне кажется, что окружающая среда не может разрешить местозаполнитель systemProperties
(см. Раздел с возвратом ошибки)Доступ к свойствам системы с помощью Spring 1.x
Может ли кто-нибудь дать мне подсказку?
контекст Применение экстракта
<bean id="props" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>file:{systemProperties['user.home']}/ldap/conf/ldapconfiguration.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="false" />
</bean>
Ошибка возвращается
Error creating bean with name 'propertyConfigurer' defined in class path resource [ApplicationContext.xml]: Cannot resolve reference to bean 'props' while setting bean property 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'props' defined in class path resource [ApplicationContext.xml]: Initialization of bean failed; nested exception is java.io.FileNotFoundException: ${systemProperties['user.home']}\ldap\conf\ldapconfiguration.properties (The system cannot find the path specified)
Спасибо.
Решение Как предусмотрено Иржи Tousek:
<bean id="props"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>file:${user.home}/ldap/conf/ldapconfiguration.properties</value>
</list>
</property>
<property name="ignoreResourceNotFound" value="false" />
Это работает !!! Большое спасибо!! – gioconno