My war file has 3 properties files: test.properties, dev.properties and prod.properties.
My application context has the following
<bean id="local" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list><value>classpath:${env}.properties</value></list> </property> <property name="ignoreResourceNotFound" value="false" /> <property name="ignoreUnresolvablePlaceholders" value="false" /> <property name="searchSystemEnvironment" value="true" /> </bean>
I have done the following
-
set the following in tomcat7/conf/web.xml
<env-entry> <env-entry-name>env</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>dev</env-entry-value> -
set the following in tomcat7/conf/context.xml
<Environment name="env" value="dev" type="java.lang.String" override="false"/> -
set CATALINA_OPTS and JAVA_OPTS
echo $CATALINA_OPTS = -Denv=dev echo $JAVA_OPTS = -Denv=dev
I start tomcat using the command, sudo /etc/init.d/tomcat7 start
This does not load any of my variables. I still get
Invalid bean definition with name 'local' defined in class path resource [applicationContext.xml]: Could not resolve placeholder 'env'
What am I doing wrong??
I was able to solve the issue by setting the variables in catalina.properties in tomcat7/conf
env = dev