打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Apache Common Configuration 初步使用

今天玩了一把Apache common configuration,感觉挺哈皮。

为了没有接触过这个工具的朋友少走弯路,我分享一下自己的经验。

1)从官网上下载一个common configuration的jar包,

http://commons.apache.org/configuration/downloads.html

我下的是commons-configuration-1.6.jar

 

2)至于怎么使用,自己看官网的说明文档吧,我也不是很懂。我主要拿它读取XML文件所以写了下面的代码

public static void main(String[] args) {

      XMLConfiguration config = null;

      try {

            config = new XMLConfiguration("Tables.xml");

            Object prop = config.getProperty("tables.table.name");

            if(prop instanceof Collection)

            {

                  System.out.println("Number of tables: " + ((Collection) prop).size());

             }

     } catch (ConfigurationException e) {

// TODO Auto-generated catch block

System.out.println("No file!");

e.printStackTrace();

}

}

 

3)报错了:No exception of type ConfigurationException can be thrown; an exception type must be a subclass of Throwable

这是因为少了一个jar包:commons-lang.jar

 

4)但是加了之后还是依然报错啊,缺包啊

java.lang.NoClassDefFoundError: org/apache/commons/logging/Log

还有一个忘记了

所以又加了两个,哈哈,成功了。

commons-collections.jar

commons-logging.jar

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
依赖jar包里的log4j配置将自己应用的log4j.properties屏蔽掉的问题
struts2 :Unable to load configuration. ……stru...
如何解决Websphere中wsjar的问题
Maven Weed
SSH项目整合开发的环境搭建
使用Slf4 j取代系统已有的 Apache Common-Logging 实现日志
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服