This should work, assuming it config-app.propertiesexists in the class path (at the root). You should not receive the error "Could not find resource for package java.util.PropertyResourceBundle."
, , ${smtp.host.name.env}, ResourceBundle. , - .
, , , - :
Properties defaultProperties = new Properties();
defaultProperties.load(new FileInputStream("config-app.properties"));
Properties properties = new Properties(defaultProperties);
if (isDev()) {
properties.load(new FileInputStream("config-dev.properties"));
} else {
properties.load(new FileInputStream("whatever.properties"));
}
properties.getProperty("smtp.host.name");
config-app.properties, config-dev.properties whatever.properties . .
config-app.properties:
smtp.host.name =localhost
config-dev.properties:
smtp.host.name =smtp.gmail.com
: , , - :
defaultProperties.load(Classname.class.getClassLoader().getResourceAsStream("config-app.properties"));