0

I want to be able to use different application.properties in my MVC REST app. I've created application-.properties for each of my enironments. I only managed to get this to work by setting -Dmyapp.env= then adding

<context:property-placeholder location="classpath:application-    ${myapp.env}.properties"  />

I was looking at spring profiles and thought that I could have an application.properties and in that file set spring.profiles.active= and the specific application-.properties file would also be read and override any proeprties set in the application.properties.. but I could not get this to work and I notice that the docs mention that this work with spring boot..

Is there a way to get this to work with a web app(not spring boot)

Daniel Cosio
  • 177
  • 1
  • 2
  • 16

1 Answers1

0

I can't seem to get profiles to work the way I want. Basically, I wanted to be able to have a base properties file. Then have environment specific property files where the same property would override the base one.. So this is what I found in lieu of using profiles..

<beans:bean     class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="locations">
            <beans:list>
                <beans:value>classpath:application.properties</beans:value>
                <beans:value>classpath:application-    ${myenv}.properties</beans:value>
            </beans:list>
        </beans:property>
    <beans:property name="ignoreResourceNotFound" value="true"/>

I can set a system property for 'myenv' to get the override properties.. If the system property is not defined it will just read the base file

Daniel Cosio
  • 177
  • 1
  • 2
  • 16