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往往是 ...
随机推荐
- Educational Codeforces Round 20 C(math)
題目鏈接: http://codeforces.com/problemset/problem/803/C 題意: 給出兩個數n, k, 將n拆分成k個數的和,要求這k個數是嚴格遞增的,並且這k個數的g ...
- Git的使用方法与GitHub项目托管方法
Git的安装 Windows上安装Git 访问网址:https://git-for-windows.github.io/ 点击Download下载,下载后双击安装包进行安装,一直"下一步&q ...
- 记录下java的个人测试方法
IDEA,用 JUnitGenerator V2. 0 做单元测试.. 如果是 SpringBoot,测试类上面加注解 @RunWith(SpringJUnit4ClassRunner.class) ...
- 【BZOJ 3233】 [Ahoi2013]找硬币
[题目 描述] 小蛇是金融部部长. 最近她决定制造一系列新的货币. 假设她要制造的货币 的面值为 x1, x2, x3… 那么 x1 必须为 1, xb 必须为 xa 的正整数倍(b>a). 例 ...
- ZOJ1221 Risk
Description Risk is a board game in which several opposing players attempt to conquer the world. The ...
- 应用日志获取-web系统
1 场景 应用使开发写的,但应用使部署再服务器上,而开发没有ssh登陆服务器的权限. so,开发总是请运维查日志,下载日志. so and so,运维要花很多时间帮开发去搞日志. 这是件很没意义的事, ...
- python 基础(十四) 正则表达式
正则表达式 概念: 正则匹配就是一个模糊的匹配 只要符合我的匹配规则 就会认为是正确的数据(精确的匹配) 1.[] #代表原子表把想要匹配的内容写入原子表中 匹配包含的任意一位字符 [a] ...
- RTT
Segger RTT的使用 一般arm系统中,如何通过电脑键盘和显示器同mcu进行交互最有效的有两种形式:arm7的semihost,cm时代的traceswo.现在jlink推出了颇具特色的rtt( ...
- Unity Shader入门精要学习笔记 - 第8章 透明效果
转载自 冯乐乐的 <Unity Shader入门精要> 透明是游戏中经常要使用的一种效果.在实时渲染中要实现透明效果,通常会在渲染模型时控制它的透明通道.当开启透明混合后,当一个物体被渲染 ...
- 一图秒懂http与https的区别
HTTPS与HTTP的一些区别 HTTPS协议需要到CA申请证书,一般免费证书很少,需要交费. HTTP协议运行在TCP之上,所有传输的内容都是明文,HTTPS运行在SSL/TLS之上,SSL/TLS ...