Java:使用哪个配置框架? [英] Java: which configuration framework to use?
问题描述
我需要决定使用哪个配置框架。目前我在使用属性文件和XML文件之间。我的配置需要有一些基本的分组,例如。以XML格式呈现为:
I need to decide which configuration framework to use. At the moment I am thinking between using properties files and XML files. My configuration needs to have some primitive grouping, e.g. in XML format would be something like:
<configuration>
<group name="abc">
<param1>value1</param1>
<param2>value2</param2>
</group>
<group name="def">
<param3>value3</param3>
<param4>value4</param4>
</group>
</configuration>
或属性文件(类似于log4j.properties):
or a properties file (something similar to log4j.properties):
group.abc.param1 = value1
group.abc.param2 = value2
group.def.param3 = value3
group.def.param4 = value4
我需要双向(读写)配置库/框架。好的功能将是 - 我可以读出不同的配置组作为不同的对象,所以我可以以后将它们传递到不同的地方,例如。 - 读取所有属于组abc作为一个对象和def作为另一个对象。如果这是不可能的,我总是可以将单个配置对象拆分为更小的自己在应用程序初始化部分当然。
I need bi-directional (read and write) configuration library/framework. Nice feature would be - that I could read out somehow different configuration groups as different objects, so I could later pass them to different places, e.g. - reading everything what belongs to group "abc" as one object and "def" as another. If that is not possible I can always split single configuration object into smaller ones myself in the application initialization part of course.
哪个框架最适合我?
推荐答案
是否可以在配置中存储对象,我建议这样:
Since you are saying that it is possible to also store objects in the config, I would suggest this:
http://commons.apache.org/configuration/
这篇关于Java:使用哪个配置框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!