In a Spring file I have:
<bean id="propertyConfigurer" class="org.myapp.MyConfigurator">
<property name="locations">
<list>
<value>classpath:configuration-${env}.properties</value>
</list>
</property>
</bean>
the ${env} variable is defined in maven's profile. But when I run from eclipse the application in tomcat 6 (published) it doesn't look in maven. So how can I set the variable for Tomcat?
Thanks
Randomize
Environment-Specific Properties File. If we need to target different environments, there's a built-in mechanism for that in Boot. We can simply define an application-environment. properties file in the src/main/resources directory, and then set a Spring profile with the same environment name.
In Spring Boot, any property can be overridden by an environment variable of the same name, with the characters changed to upper case, and the dots changed to underscores. This means that if we want to override any property, we can do it by setting an environment variable in the container.
Add system variable in Eclipse: Go to Run --> Run Configurations --> Tomcat
Select Arguments tab and add to VM arguments -Denv=blabla
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With