管理复杂的配置
我想询问您对管理大量复杂(例如 xml、.properties、自定义格式等)配置文件的最佳实践的看法,因为现在每个更复杂的项目都包含大量的配置文件。
如何在如此混乱的环境中不迷失方向?如何以最佳方式重用它们?有什么好的工具可以提供帮助吗(也许是一些基于 Eclipse 的工具)?
I would like to ask you for your opinion on the best practices of managing big numbers of complex (for example xml, .properties, custom formats etc) configuration files as nowadays every more complex project consist of way to many to count.
How not to get lost in such a mess? How to reuse those in best ways? Any good tool that can help (maybe some Eclipse based)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,最基本的事情是将这些配置文件放入源代码管理中,因为它们实际上是一种源代码。
但配置管理的真正挑战是决定有多少文件以及将哪些文件放在哪里,以便您可以重用通用配置。这些是设计决策,并且非常特定于项目和环境,没有任何工具可以为您做出这些决策。
一种常见的方法是拥有一个包含默认值的主配置文件,以及仅包含与其环境不同并覆盖默认值的配置值的特定于环境的文件。这是作为自动构建过程的一部分发生的(您真的非常应该这样做)。
Obviously, the most fundamental thing to do is to put those configuration files into source control, as they really are a kind of source code.
But the real challenge with configuration management is deciding how many files to have and what to put where so that you can reuse common configurations. Those are design decisions and very project- and environment-specific, and no tool can make them for you.
A common approach is to have a master config file that contains default values, and environment-specific files that contain only those config values that are different for their environment, and which overwrite the defaults. This happens as part of an automated build process (which you really, really should have).
我不确定这是否适用于您的情况,但我会尝试以标准化方式将它们全部存储在数据库中。也许您需要一个可以编写一些导入工具来从文件中获取信息并将它们添加到数据库中。
或者阅读此,或这可能对您有帮助。
I'm not sure if this would be applicable to your situation, but I'd try and store them all in a database in a normalised fashion. maybe you need a could write some import tools that grabs the info from the files and adds them to the db.
Alternativly reading this, or this might help you.