We are working on Spring Boot 2.1.6 and we need to implement spring boot profile in our application
We have currently two property files application.properties and bucket.properties(s3 configuration) file in our project.
so we have created the two properties files resources/application-dev.properties and resources/bucket-dev.properties file for Dev environment.
We are passing the VM arguments in the below program -Dspring.profiles.active=dev so that it pickup the files correctly.
We are using XML based configuration and hence we are loading the property file using below definition.
<bean id="applicationProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name="locations" >
<list>
<value>classpath:application-${spring.profiles.active:dev}.properties</value>
<value>classpath:bucket-${spring.profiles.active:dev}.properties</value>
</list>
</property>
</bean>
Above configuration is working fine and spring boot is able to pickup the files properly.
But I want to create the below kind of folder structure in resources folder to segregate the files properly.
|
resources
|dev
|
application-dev.properties
bucket-dev.properties
As soon as I do that I have made changes in the above PropertyPlaceholderConfigurer like below.
<bean id="applicationProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name="locations" >
<list>
<value>classpath:${spring.profiles.active}/application-${spring.profiles.active:dev}.properties</value>
<value>classpath:${spring.profiles.active}/bucket-${spring.profiles.active:dev}.properties</value>
</list>
</property>
</bean>
As soon as I start the application using the above configuration it is failed to locate the properties define inside the above file and failing to start App.
Please let me know what I am missing in the above configuration.
Note: We are not using Annotation based configuration in Spring Boot App but using only XML based configuraton.
application-*.properties(at least) at all; that's entirely a job that Boot does. - chrylis -cautiouslyoptimistic-PropertyPlaceholderConfigurer. you can try with--spring.config.locationoption. But I doubt it will work - pvpkiran