首页 > 解决方案 > PPlay 2.6:Config中Configuration.path的等效API

问题描述

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

任何帮助。

谢谢

标签: playframework

解决方案


您需要注入 Environment 类。

private final Environment environment;

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

现在获取根路径:

environment.rootPath();

推荐阅读