Hi!
I'm new with spring and new in this forum.
I already searched a lot for the use of environment variable in spring but I still couldn't make it work.
I have a Java application in which I have a bean like this:
Whenever I try to use the bean like this, it doesn't work.Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="dev" class="org.test.bean.ConfigBean"> <property name="propsFile" value="${jboss.server.config.url}/props/a.properties" /> </bean> </beans>
So I read about the PropertyPlaceholderConfigurer, and I tried something like this:
and inside the app.properties I have:Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:app.properties" /> <property name="ignoreResourceNotFound" value="false" /> <property name="searchSystemEnvironment" value="true" /> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> </bean> <bean id="dev" class="org.test.bean.ConfigBean"> <property name="propsFile" value="${test}" /> </bean> </beans>
test=${jboss.server.config.url}/props/a.properties
But whenever I try to load the propsFile value in my java project it gets only the ${test}.
What am I missing?!
Thanks


Reply With Quote
