的环境变量,我需要从我applicationContext.xml
阅读从applicationContext.xml中
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="${PATH_ENV}/myprop.properties" />
</bean>
我怎样才能做到这一点看在我的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>
定义的环境变量?
最后,我已经做了下:
1 context.xml中定义的环境变量:
<Environment name="PATH_ENV" type="java.lang.String"/>
2在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>
ENV进入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-入门价值为什么?
如果有人遇到这个问题,它应该是'文件:C:/ V3/ env-entry-value>' –
Jamie