Чтение переменной среды из applicationContext.xml
Мне нужно прочитать переменную среды, определенную в моем web.xml
<env-entry>
<description>Path Repositorio NFS</description>
<env-entry-name>PATH_ENV</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>C:/V3</env-entry-value>
</env-entry>
от моегоapplicationContext.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${PATH_ENV}/myprop.properties" />
</bean>
Как я могу это сделать ?
Наконец-то я сделал следующее:
1 Определите переменную среды в context.xml:
<Environment name="PATH_ENV" type="java.lang.String"/>
2 Определите env-запись в web.xml
<env-entry>
<description>Path Repositorio NFS</description>
<env-entry-name>PATH_ENV</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>/WEB-INF/</env-entry-value>
</env-entry>
3 Определите в applicationContext.xml
<bean id="configurationPath" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/PATH_ENV</value>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<bean factory-bean="configurationPath" factory-method="concat">
<constructor-arg value="myprop.properties"/>
</bean>
</property>
</bean>
Это выполняется правильно, однако, если я определю полный путь в:
<env-entry-value>C:/V3/</env-entry-value>
У меня есть следующая проблема:
java.io.FileNotFoundException: Could not open ServletContext resource [/C:/V3/aesantasa.properties]
Я не могу определить полный путь в env-entry-value Почему?