Files for setting up spring-boot application configuration
If you currently have your application secrets either:
- hardcoded in the Java
- hardcoded in an
application.properties
- in
application.properties
which is in.gitignore
then the four files in the subdirectory config
in this repo are just what you need.
env.sh
setHerokuEnv.py
localhost.json.SAMPLE
heroku.json.SAMPLE
- Clone this repo as a sibling of your repo
cd
into your repo, and then do:cp ../spring-boot-app-config/config/* .
- Then, add these files to your .gitignore
localhost.json heroku.json
- Commit these four new files to your repo (and the changes .gitignore)
-
cp localhost.json.SAMPLE localhost.json
-
Edit
localhost.json
with the values that you need. -
Execute
source env.sh
OR. env.sh
Those both do the same thing. NOT the same as
./env.sh
The space between
.
andenv.sh
is on purpose.This defines an environment variable
SPRING_APPLICATION_JSON
which has property values that override the ones in yoursrc/main/resources/applicaiton.properties
orsrc/main/resources/application.yml
with new values.Those are the values you use when running on localhost.
The file
localhost.json.SAMPLE
should contain "fake data" for all the values you need, and the README.md should explain how to set up real values (e.g. how to set up github oauth, or firebase credentials, or google oauth, or an mlab database, etc. etc.)
-
Copy from
heroku.json.SAMPLE
toheroku.json
-
Edit the file to set the values for heroku
-
Run
./setHerokuEnv.py --app name-of-your-herokuapp
If you get a permission error, do this first:
chmod u+x setHerokuEnv.py`
This sets the config variables on Heroku to the values in your
heroku.json
. You can see those value in the Heroku dashboard config vars.