Issue
How I can hide string from my mvc-dispatcher-servlet.xml, when I public code on GitHub?
I can't exclude this file - it contain many important settings!
Solution
In my opinion your best bet is to use O/S environment variables for such things. That's what Heroku does, and they are a-ok.
Reasons:
- cross-platform
- easily read by many programming languages
- only user or root can read
- survives reboot
- never check passwords into source control by accident
- easy to have different config on different machines without editing any files
If you use a <context:property-placeholder />
in your spring app context config then Spring can read O/S env vars like $USERNAME
You might have to restart your IDE after changing env vars though.
Answered By - Neil McGuigan
Answer Checked By - Willingham (JavaFixing Volunteer)