Class ServerPropertiesTool

java.lang.Object
com.github.theword.queqiao.tool.utils.ServerPropertiesTool

public final class ServerPropertiesTool extends Object
server.properties 读取工具。

类加载时会完成一次路径推断和文件读取,并将结果缓存到内存。

后续调用直接命中缓存,避免反复 IO。

  • Method Details

    • getServerPropertiesPath

      public static Path getServerPropertiesPath()
      获取 server.properties 绝对路径。
    • refresh

      public static void refresh()
      刷新 server.properties 缓存。

      在 reload 等场景下调用,可确保后续读取到最新配置。

    • getValue

      public static String getValue(String key)
      通过 key 获取 server.properties 配置值。

      找不到 key 或配置文件不存在时返回 null。