1.官网 http://commons.apache.org/proper/commons-configuration/
The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources。
maven配置
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.2</version>
</dependency>
2.对xml的读取,使用XMLConfiguration。
详见 http://commons.apache.org/proper/commons-configuration/apidocs/index.html
3.demo
XMLConfiguration xmlConfiguration = new XMLConfiguration(“xml文件路径”);
ConfigurationNode node = xmlConfiguration.getRootNode();
List<ConfigurationNode> grouponNodes = node.getChildren();
使用下面的方式获取数据
// 获取mapper的bean名
ConfigurationNode mapperNode = (ConfigurationNode) grouponNode.getChildren("mapper").get(0);
String mapperBeanName = mapperNode.getValue().toString();