首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

java学习札记6 - 使用commons configuration管理配置文件

2013-01-17 
java学习笔记6 - 使用commons configuration管理配置文件Commons Configuration是一个java应用程序的配置

java学习笔记6 - 使用commons configuration管理配置文件

Commons Configuration是一个java应用程序的配置管理类库。可以从properties或者xml文件中加载软件的配置信息,用来构建支撑软件运 行的基础环境。在一些配置文件较多较的复杂的情况下,使用该配置工具比较可以简化配置文件的解析和管理。也提高了开发效率和软件的可维护性。

官方主页:http://commons.apache.org/configuration/

它目前支持的配置文件格式有:

Properties files 
XML documents 
Windows INI files 
Property list files (plist) 
JNDI 
JDBC Datasource 
System properties 
Applet parameters 
Servlet parameters

我使用的是目前最新版本1.9,以调用 Properties格式的文件为例,使用方法如下:

基本用法:

1.加载jar包,我使用maven自动加载,pom.xml配置如下:

configUtil.get("/common/velocity.properties", "input.encoding");



热点排行