三种格式文件比较 .properties .conf .json

来源:互联网 发布:ubuntu qemu xp 编辑:程序博客网 时间:2024/06/05 03:48

The three file formats each have advantages.

  • Java .properties:
    • Java standard, built in to JVM
    • Supported by many tools such as IDEs
  • JSON:
    • easy to generate programmatically
    • well-defined and standard
    • bad for human maintenance, with no way to write comments, and no mechanisms to avoid duplication of similar config sections
  • HOCON/.conf:
    • nice for humans to read, type, and maintain, with more lenient syntax
    • built-in tools to avoid cut-and-paste
    • ways to refer to the system environment, such as system properties and environment variables

The idea would be to use JSON if you're writing a script to spit out config, and use HOCON if you're maintaining config by hand. If you're doing both, then mix the two.

0 0
原创粉丝点击