http://commons.apache.org/configuration/apidocs/index.html
Commons Configuration provides a generic configuration interface which enables a Java application to
read configuration data from a variety of sources.
PropertiesConfiguration Loads configuration values from a properties file.
XMLConfiguration Takes values from an XML document.
INIConfiguration Loads the values from a .ini file as used by Windows.
PropertyListConfiguration Loads values from an OpenStep .plist file. XMLPropertyListConfiguration is
also available to read the XML variant used by Mac OS X.
JNDIConfiguration Using a key in the JNDI tree, can retrieve values as configuration properties.
BaseConfiguration An in-memory method of populating a Configuration object.
HierarchicalConfiguration An in-memory Configuration object that is able to deal with complex
structured data.
SystemConfiguration A configuration using the system properties
ConfigurationConverter Takes a java.util.Properties or an
org.apache.commons.collections.ExtendedProperties and converts it to a Configuration object.
1.读取XML文件中内容
global.xml:
2.读取properties文件
global.properties:
3.当有多个配置文件时,就利用ConfigurationFactory对象来访问多个不同的配置资源
ConfigurationFactory可以组合多个配置资源。然后我们就可以像访问单个资源文件一样来访问他们中的属性。首
先,我们需要创建一个xml文件来告诉工厂哪些文件将要被加载。下面是一个例:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<properties fileName="usergui.properties"/>
</configuration>
ConfigurationFactory的定义文件是一个普通的xml文件.根元素是configuration.他饱含的子元素制定了需要装载
的配置资源.properties是元素之一,他用来包含属性文件
additional-xml-configuration.xml:
或者采用另外一种方法: 用到了:CompositeConfiguration,手动加上两个配置文件
转帖出处:http://blog.csdn.net/pengchua/archive/2007/12/21/1957069.aspx