I have an app on Spring Boot that running in two environments, local and heroku:
Local - connect to DB is configured by app.properties.
Heroku - app is working w\o app.properties, using one environment variable:
heroku config -a zed-social-network === zed-social-network Config Vars CLEARDB_DATABASE_URL: mysql://{login}:{pass}@host.com/heroku?reconnect=true&useUnicode=true&characterEncoding=UTF-8
Question: how I can configure DB connect in Spring on local machine in same style, with one env variable?
I would use a command line argument:
mvn spring-boot:run -Drun.arguments=--customArgument=custom
so in your case
mvn spring-boot:run -Drun.arguments=--CLEARDB_DATABASE_URL=your_url
--
Alternatively, you could add the url to system variables and then reference it in application.properties like so:
spring.datasource.url=${NAME_OF_THE_SYSTEM_VARIABLE}