使用Commons Configuration可以很好的管理我们的配置文件的读写,
官网:http://commons.apache.org/configuration
需要用到commons-lang,commons-collections,commons-logging,log4j jar包
publicclassTest{publicstaticvoidmain(String[]args)throwsConfigurationException,InterruptedException{xmlLoadTest();fileLoadTest();saveTest();runtimeReload();}//xml文件publicstaticvoidxmlLoadTest()throwsConfigurationException{Stringfile="test1.xml";XMLConfigurationconfig=newXMLConfiguration(Test.class.getResource(file));System.out.println(config.getString("conf.url"));System.out.println(config.getDouble("conf.money"));}//properties文件privatestaticvoidfileLoadTest()throwsConfigurationException{Stringfile="test2.properties";PropertiesConfigurationconfig=newPropertiesConfiguration(Test.class.getResource(file));System.out.println(config.getString("url"));}//保存到文件publicstaticvoidsaveTest()throwsConfigurationException{Stringfile="test2.properties";PropertiesConfigurationconfig=newPropertiesConfiguration(Test.class.getResource(file));//设置自动保存或显示调用config.save();config.setProperty("colors.background","#000000");config.setAutoSave(true);}//运行期参数修改加载publicstaticvoidruntimeReload()throwsConfigurationException,InterruptedException{Stringfile="test2.properties";PropertiesConfigurationconfig=newPropertiesConfiguration(Test.class.getResource(file));config.setReloadingStrategy(newFileChangedReloadingStrategy());System.out.println(config.getString("url"));Thread.sleep(10000);//在休眠期间,手动修改文件里面的url值后观察日志情况System.out.println(config.getString("url"));}}
您还没有登录,请您登录后再发表评论
apache commons 工具包中提供的一个针对配置文件动态修改的工具类
apache configuration api_zh
Apache配置演示 Apache Commons Configuration 2学习
org.apache.commons.configuration.XMLConfiguration的读取范例
Maven坐标:org.apache.commons:commons-configuration2:2.1.1; 标签:apache、commons、configuration2、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
离线安装包,测试可用
apache commons all 中文api合集
apache-sanselan-incubating-0.97-bin bcel-5.2 commons-beanutils-1.9.2-bin commons-chain-1.2-bin commons-cli-1.3.1-bin commons-codec-1.10-bin commons-collections4-4.0-bin commons-configuration-1.10-bin...
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
apache Commons Lang 2.4 API apache Commons Lang 2.4 API
apache commons jar(commons所有的jar包,从官网下载提供给大家) 因为涉及jar太多,包括有src源代码,只需要3分,希望大家理解,我也是从官网花了很长时间才一个一个下完,需要的请自取。全部是zip文件,每个对应的...
Apache Commons Collections的使用指南,该jar包提供了多数集合的线程安全版本,以及增强了大多数的集合功能,送给那些不想重复发明轮子的人.
Commons-beanutils-API Commons-collections-API Commons-configuration-API Commons-lang-API Commons-logging-API Dom4j_API java api javascript Struts API J2EE API
Apache Commons API简介,主要介绍Apache Commons API所包含的包,后续更新补充各类的简介和使用方法
Apache Commons Collections,commons-collections-3.2.1和commons-collections4-4.0,含jar包及源码和api文档。
commons-configuration2-2.0.jar Apache commons-configuration 读取配置文件
Apache Commons是一个非常有用的工具包,解决各种实际的通用问题。(附件中提供了该工具包的jar包,及源文件以供研究) BeanUtils Commons-BeanUtils 提供对 Java 反射和自省API的包装 Betwixt Betwixt提供将 ...
主要介绍了Apache Commons Math3探索之多项式曲线拟合实现代码,小编觉得挺不错的,这里分享给大家,供需要的朋友参考。
博文链接:https://log-cd.iteye.com/blog/211727
相关推荐
apache commons 工具包中提供的一个针对配置文件动态修改的工具类
apache configuration api_zh
Apache配置演示 Apache Commons Configuration 2学习
org.apache.commons.configuration.XMLConfiguration的读取范例
Maven坐标:org.apache.commons:commons-configuration2:2.1.1; 标签:apache、commons、configuration2、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
离线安装包,测试可用
apache commons all 中文api合集
apache-sanselan-incubating-0.97-bin bcel-5.2 commons-beanutils-1.9.2-bin commons-chain-1.2-bin commons-cli-1.3.1-bin commons-codec-1.10-bin commons-collections4-4.0-bin commons-configuration-1.10-bin...
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
apache Commons Lang 2.4 API apache Commons Lang 2.4 API
commons-lang3.3.1.jar、Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。为JRE5.0+的更好的版本所提供 Jar文件包含的类: META-INF/MANIFEST.MFMETA-INF/LICENSE....
apache commons jar(commons所有的jar包,从官网下载提供给大家) 因为涉及jar太多,包括有src源代码,只需要3分,希望大家理解,我也是从官网花了很长时间才一个一个下完,需要的请自取。全部是zip文件,每个对应的...
Apache Commons Collections的使用指南,该jar包提供了多数集合的线程安全版本,以及增强了大多数的集合功能,送给那些不想重复发明轮子的人.
Commons-beanutils-API Commons-collections-API Commons-configuration-API Commons-lang-API Commons-logging-API Dom4j_API java api javascript Struts API J2EE API
Apache Commons API简介,主要介绍Apache Commons API所包含的包,后续更新补充各类的简介和使用方法
Apache Commons Collections,commons-collections-3.2.1和commons-collections4-4.0,含jar包及源码和api文档。
commons-configuration2-2.0.jar Apache commons-configuration 读取配置文件
Apache Commons是一个非常有用的工具包,解决各种实际的通用问题。(附件中提供了该工具包的jar包,及源文件以供研究) BeanUtils Commons-BeanUtils 提供对 Java 反射和自省API的包装 Betwixt Betwixt提供将 ...
主要介绍了Apache Commons Math3探索之多项式曲线拟合实现代码,小编觉得挺不错的,这里分享给大家,供需要的朋友参考。
博文链接:https://log-cd.iteye.com/blog/211727