Reputation: 7465
I have a Spring Boot application for which I keep a base application.properties
, and then a couple of application-${profile}.properties
files with configuration valid for several development environments.
I want to keep those application-${profile}.properties
files in source control, but as they contain private development environment details, I want to be able to create a jar
package without them for distribution to third parties (i.e. only with the base application.properties
). This would force users to add their own application.properties
to the classpath when executing (or configure in other ways), which is what I intend.
I understand I could move those profile configuration files elsewhere instead of src/main/resources
so that mvn package
ignores them, then add such folder to the classpath in IDE configurations... but I think there probably is a more integrated, elegant way of doing this with Boot that I'm missing...
Upvotes: 0
Views: 2759
Reputation: 5420
I have not done it myself but according to the documentation, the application is reading properties from following locations
/config
subdirectory of the current directory. /config
package Then you can do
java -jar myproject.jar --spring.config.name=nameofpropertiesfile
Upvotes: 2