Reputation: 1197
What is the best way to configure a Spring Boot application to connect to MongoDB on Heroku? I got it working specifying spring.data.mongodb.uri
in the application.properties file, but I would like to set the connection up, so that I can keep the application pointing to my local MongoDB during development, while being able to push to Heroku without reconfiguring the connection URI each time.
Thanks, Jerry
Upvotes: 2
Views: 2693
Reputation: 116271
You could use profile-specific configuration to specify the URIs to use during development and when deploying to Heroku. A file named application-{profile}.properties
will only be loaded when the matching profile is active, i.e. you could use a file named application-heroku.properties
and enable the heroku
profile when deploying to Heroku. Any profile-specific configuration will override the default configuration in application.properties
. You can enable a profile using spring.profiles.active
, for example:
java -jar your-app.jar --spring.profiles.active=heroku
Upvotes: 2