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往往是 ...
随机推荐
- lightoj 1078【同余定理】
题意: 给你一个n和一个数 digit ,问你最少需要多少个 digit 使得整除于n; 思路: 同余定理(a+b)%n=(a%n+b%n)%n; (m%n+m%n*10+m%n*100+m%n*10 ...
- C#基础知识回顾
值类型和引用类型 值类型存在栈上,结构,枚举,数值类型 引用类型存在堆上,数组,类,接口,委托 把值类型存到引用类型中就是封箱,耗时 引用类型中的值类型是存在堆上,不是栈上,但是作为参数传递时,还是会 ...
- C#:索引
1. 什么是索引 索引是一组get和set访问器,类似于属性的访问器. 2. 索引和属性 和属性一样,索引不用分配内存来存储 索引和属性都主要被用来访问其他数据成员,这些成员和它们关联,它们为这些成员 ...
- ES6函数参数默认值作用域的模拟原理实现与个人的一些推测
一.函数参数默认值中模糊的独立作用域 我在ES6入门学习函数拓展这一篇博客中有记录,当函数的参数使用默认值时,参数会在初始化过程中产生一个独立的作用域,初始化完成作用域会消失:如果不使用参数默认值,不 ...
- Excel - 使用公式将秒转换为分+秒
场景 现在有个需求:将Excel里的时间转换为分+秒的格式,如下: time(second) time(min+second) 482.712 XXmin,XXs 480.737 XXmin,XXs ...
- springMVC 类型转换
springMVC 类型转换 https://www.cnblogs.com/hafiz/p/5812873.html
- netty与MQ使用心得
最近在做分布式的系统,使用netty与mq进行远程RPC调用,现将心得经验总结一下. 我们公司的服务器在云端机房,在每一个店面有一个服务器,店面服务器外网无法访问. 我们的做法是店面服务器在启动时与云 ...
- centos安装openldap过程
1.下载软件如下,db是数据库 2.首先安装数据库db # tar xf db-4.8.30.tar.gz # cd db-4.8.30 # cd build_unix/ (# ../dist/con ...
- 转 如何快速清理 chrom 缓存
谷歌浏览器(Chrome)如何手动清除缓存 听语音 | 浏览:13267 | 更新:2014-05-15 01:00 | 标签:谷歌 chrome 浏览器的缓存可以帮助我们更好地使用一些程序,但时间长 ...
- Unity Shader入门精要学习笔记 - 第14章非真实感渲染
转载自 冯乐乐的 <Unity Shader 入门精要> 尽管游戏渲染一般都是以照相写实主义作为主要目标,但也有许多游戏使用了非真实感渲染(NPR)的方法来渲染游戏画面.非真实感渲染的一个 ...