Reputation: 3
I am using spring boot and I have added another spring boot app as Maven dependency in my project. The problem I am facing is that when I run the application, it picks the property file of the dependency instead of my current application. For example if I run the app using dev profile, application-dev.property file is picked from dependency instead of the running application. I tried to debug the EnableEncryptablePropertySourcesPostProcessor file and below is the screenshot of the list of property file picked.
Upvotes: 0
Views: 3385
Reputation: 61
**In Application.java file it should be something like this
@PropertySource("classpath:application.properties")
Upvotes: 0
Reputation: 692
Use PropertySource annotation to refer the properties file in your main application file as shown below
@PropertySource(value = { "file:/path/to/folder/file.properties" })
If you have same property in the multiple properties file then one in the classpath will get more preference
Upvotes: 1
Reputation: 9635
Check this out but you have a few options:
Simply specify the config file name:
java -jar myproject.jar --spring.config.name=myproject
And basically you can have myproject-dev.properties
Or directly specify the config files you wanna import:
java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties
Upvotes: 1