Heroku uses environment variables to store and read application configuration, including sensitive information (i.e. passwords). It also has the benefit of being able to run the application on different contexts, development and production, without changing config files or even source code.
Jhipster uses configuration files, application-dev.yml and application-prod.yml, to store datasource configuration -passwords included- This files are subject to source control, this is not acceptable.
I was trying to figure out how to read properties from environment variables in a jhipster generated application, and it happens that it already does since it uses Spring Boot which provides a feature to read external configurations with plenty of options -included environment variables-
To configure the datasource I created an
.env file (heroku convention) which exports the environment variables
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost/devdb export SPRING_DATASOURCE_USERNAME=scott export SPRING_DATASOURCE_PASSWORD=secret
notice how each variables is mapped to its counterpart in the yml file
spring: datasource: url: username: password:
finally you only need to /source the .env file prior to running
mvn spring-boot:run with the command
source .env or