I deployed my spring boot .war file in WebSphere 8.5.5 server and I have enabled spring profiles in application.properties file to read application specific properties files. But I am not sure how to read the external application.properties files using spring profiles in WebSphere. And spring profile is working when I package the war file with all properties file but I want to place the properties file outside of war.
- Below are the steps I did:
I am reading the external properties files using @PropertySource in spring boot application java file but it is accessing the file only specific to the path. below is the code snippet
@PropertySource({"file: /opt/config/application.properties"}
Application.properties
file has onlyspring.profiles.active-dev
I placed application-dev.properties file in the same path but spring boot app is not able to read the dev file. it just able to read application.property file which is given in @PropertySource. My requirement is:
- I want place below 3 files in external path in WebSphere
application.properties
application-dev.properties
application-qa.properties
application-prod.properties
- I will enable spring profile in application.properties file and spring boot application should able to read the respective environment specific property file.
- If I package all 4 properties files in war file then profiling is working but when place them in external path it is unable read them in WebSphere.
As per my knowledge, spring boot app can read external config files outside of spring boot jar from same path. But I am not sure how to read same files from external path in webSphere server. Please help me with sample code snippet and steps to implement spring profile for WebSphere.