java - Multiple projects retrieving credentials from a local file -
i have several different projects , of them hardcode server names, db user , passwords.
i have found of places need changed in order point new server, there @ least 50 instances same change required, looks terrible design.
i change information centralized no 1 else have go hunting again. have read setting environment variables, preferably include information projects such reading sort of configuration file.
how should approach this?
how properties file? can use suggested here :
public class app { public static void main( string[] args ) { properties prop = new properties(); try { //load properties file prop.load(new fileinputstream("config.properties")); //get property value , print out system.out.println(prop.getproperty("database")); system.out.println(prop.getproperty("dbuser")); system.out.println(prop.getproperty("dbpassword")); } catch (ioexception ex) { ex.printstacktrace(); } } }
Comments
Post a Comment