【问题标题】:PLay 2.6: Equivalent API of Configuration.path in ConfigPPlay 2.6:Config中Configuration.path的等效API
【发布时间】:2020-05-17 18:26:06
【问题描述】:

我现在使用的是从 Play 2.4 迁移而来的 play 2.6。 在播放 2.4 中,我使用的是 Configuration.path().getAbsolutePath(); 根据 play 2.6 文档,配置被替换为 com.typesafe.config.Config; 但我在这里没有看到任何等效的 path() api。

任何帮助。

谢谢

【问题讨论】:

    标签: playframework


    【解决方案1】:

    您需要注入 Environment 类。

    private final Environment environment;
    
    @Inject
    public YourConstructor(Environment environment)
        this.environment = environment;
    }
    

    现在获取根路径:

    environment.rootPath();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-02
      • 2014-08-15
      • 2016-11-13
      • 2017-04-22
      • 2019-10-06
      • 1970-01-01
      • 2012-01-13
      相关资源
      最近更新 更多