Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat + Spring and environment variables

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

like image 318
Randomize Avatar asked Oct 26 '11 14:10

Randomize


People also ask

How do I set environment specific properties in spring boot?

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.

How does spring boot allow us to override default configuration values for each environment?

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.


1 Answers

Add system variable in Eclipse: Go to Run --> Run Configurations --> Tomcat Select Arguments tab and add to VM arguments -Denv=blabla

like image 62
Tarlog Avatar answered Oct 27 '22 18:10

Tarlog