Apache Commons Configuration的应用
Configuration parameters may be loaded from the following sources:
XML documents
Windows INI files
Property list files (plist)
JNDI
JDBC Datasource
System properties
Applet parameters
Servlet parameters
| Component | Dependencies |
|---|---|
| Core | Java 1.3 commons-collections commons-lang commons-logging |
| ConfigurationFactory | commons-digester commons-beanutils Java 1.4 or xml-apis |
| DefaultConfigurationBuilder | commons-beanutils Java 1.4 or (xml-apis + xerces + xalan) |
| DatabaseConfiguration | JDBC 3.0 (Java 1.4 or jdbc2_0-stdext.jar) |
| XMLConfiguration | Java 1.4 or (xml-apis + xerces + xalan) |
| XMLPropertiesConfiguration | Java 1.4 or (xml-apis + xerces) |
| PropertyListConfiguration | commons-codec |
| XMLPropertyListConfiguration | commons-codec Java 1.4 or xml-apis |
| ConfigurationDynaBean | commons-beanutils |
| XPathExpressionEngine | commons-jxpath |
| EnvironmentConfiguration | Java 1.5 or ant 1.6.5 |
import org.apache.commons.configuration.*;
/**
* Commons Configuration读取属性文件的例子
*
* @author leizhimin 2008-9-23 9:40:17
*/
public class Test1 {
public static void main(String[] args) throws ConfigurationException {
test1();
}
public static void test1() throws ConfigurationException {
CompositeConfiguration config = new CompositeConfiguration();
//config.addConfiguration(new SystemConfiguration());
config.addConfiguration(new PropertiesConfiguration("cfgtest/test1.properties"));
String usernaem = config.getString("username");
String password = config.getString("password");
System.out.println(usernaem + " " + password);
}
}
password = leizhimin
Process finished with exit code 0
Apache Commons Configuration的应用的更多相关文章
- 使用Apache Commons Configuration读取配置信息
在项目中使用一些比较新的库总会给你带来很多快乐,在这篇文章中,我将会给你介绍一个在Java中读取配置文件的框架——Apache Commons Configuration framework. 你会了 ...
- Apache Commons Configuration读取xml配置
近期项目自己手写一个字符串连接池.因为环境不同有开发版本.测试版本.上线版本.每一个版本用到的数据库也是不一样的.所以需要能灵活的切换数据库连接.当然这个用maven就解决了.Apache Commo ...
- Apache Commons configuration使用入门
使用Commons Configuration可以很好的管理我们的配置文件的读写, 官网:http://commons.apache.org/configuration 需要用到commons-la ...
- commons configuration管理项目的配置文件
Commons Confifutation commons configuration可以很方便的访问配置文件和xml文件中的的内容.Commons Configuration 是为了提供对属性文件. ...
- Apache Commons 常用工具类整理
其实一直都在使用常用工具类,只是从没去整理过,今天空了把一些常用的整理一下吧 怎么使用的一看就明白,另外还有注释,最后的使用pom引入的jar包 public class ApacheCommonsT ...
- Commons Configuration之二基本特性和AbstractConfiguration
Configuration接口定义一大堆方法.一切从头开始实现这些方法非常困难.因为AbstractConfiguration类存在.该类在Commons Configuration中充当大多数Con ...
- Apache Commons CLI命令行启动
今天又看了下Hangout的源码,一般来说一个开源项目有好几种启动方式--比如可以从命令行启动,也可以从web端启动.今天就看看如何设计命令行启动... Apache Commons CLI Apac ...
- 编写更少量的代码:使用apache commons工具类库
Commons-configuration Commons-FileUpload Commons DbUtils Commons BeanUtils Commons CLI Commo ...
- Apache Commons 工具集
一.Commons BeanUtils http://jakarta.apache.org/commons/beanutils/index.html 说明:针对Bean的一个工具集.由于Bean往往是 ...
随机推荐
- perl C/C++ 扩展(二)
第二讲perl 加载c/c++的库 先通过h2xs 创建一个新的工程 h2xs -A -n two_test 进入目录 cd two_test 创建一个mylib文件夹,存放静态库 mkdir myl ...
- JavaScript 原生提供两个 Base64 相关的方法
JavaScript 原生提供两个 Base64 相关的方法. btoa():任意值转为 Base64 编码 atob():Base64 编码转为原来的值 var string = 'Hello Wo ...
- SRE思想
1 规模效应 业务越庞大,服务器就越多,服务越多,就越需要拆分成分布式架构.架构越复杂,对运维的能力要求就越高.出错的概率就越大,运维的工作量就越大.因此就要更多开发提升效率的工具. 而在小企业,业务 ...
- jmeter beanshell处理请求响应结果时Unicode编码转为中文
在Test Plan下创建一个后置BeanShell PostProcessor,粘贴如下代码即可: String s=new String(prev.getResponseData()," ...
- 在b站做计网实验 - 抓包/get/post
前言 这篇博文是一个小实验,用python发送get/post请求,其中用到cookie登录bilibili网站并修改个人信息. 抓包 对HTTP应用而言,用浏览器自带的插件可以很方便做到抓包,比如c ...
- echarts 百度地图 json
百度ECharts地图Json数据在线下载 最近需要写一个echarts地图统计表,苦于弄不到对应的地图json文件, CSDN 上下载的很多不完整或者不能用,功夫不负苦心人找到了这个. 阿里云地图选 ...
- idea获取激活码
访问地址拿到激活码:http://idea.lanyus.com/getkey
- linux分配文件文件夹所属用户及组
ls -l 可以查看当前目录文件.如:drwxr-xr-x 2 nsf users 1024 12-10 17:37 下载文件备份分别对应的是:文件属性 连接数 文件拥有者 所属群组 文件大小 文件修 ...
- disasters
1.list all the natural disasters to the best of your knowledge. 2.What are the possible causes for s ...
- 我喜欢的两个js类实现方式 现在再加上一个 极简主义法
闭包实现 变量是不会变的:) var myApplication = function(){ var name = 'Yuri'; var age = '34'; var status = 'sing ...