Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fedotxxl/fdffb9d8475b43b34dc1ef05c3d19ffa to your computer and use it in GitHub Desktop.
Save fedotxxl/fdffb9d8475b43b34dc1ef05c3d19ffa to your computer and use it in GitHub Desktop.
//<import resource="applicationContext.log.db.${log.to.db:false}.xml"/>
//http://stackoverflow.com/questions/3035630/how-to-achieve-conditional-resource-import-in-a-spring-xml-context
private void loadConditionalProperties() {
try {
Properties properties = new Properties();
try (InputStream stream = FileUtils.openInputStream(new File(getDefaultConfigPath()))) {
properties.load(stream);
}
System.setProperty("log.to.db", properties.getProperty("log.to.db", "false"));
} catch (Exception e) {
loge.error("context.conditional.e", e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment