I've been reading a bit about how to provide application properties to my jee project for some time ago.
By aplication properties
I mean for example where the database is located, or the user or password...
There are several ways to achive that:
- Using a project .properties file. Problems:
- critical information (user, password, API keys... are in this file),
- this information can change according the target machine (I could set up a machine with a mysql using a
user1
and by other hand I could set up a machine with a mysql usinguser2
). The content of this file shouldn't be maintained on source code.
- Using OS environment variables.
- There are some peaple that prefers this way to provide properties. Nevertheless, I think it's not quite a safer way to achieve that. Anyone get access on the machine is going to be able to read the content of these environment variables.
- I've also read that it's able to use
web.xml
but I don't quite know how could I get my goal.
Is there any best practices guide for getting this?