playframework - 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。
任何帮助。
谢谢
解决方案
您需要注入 Environment 类。
private final Environment environment;
@Inject
public YourConstructor(Environment environment)
this.environment = environment;
}
现在获取根路径:
environment.rootPath();
推荐阅读
- android - 下面给出的android中这行代码的含义......?
- ionic-framework - 如何在 Ionic 4 的组件中访问提供者成员
- wordpress - ACF 复选框元查询
- docker - 为 laravel 应用程序设置 Docker 我在“compose/cli/main.py”中遇到错误
- android - 未能加载激励视频广告错误代码 3
- transactions - 事务的提交如何工作?
- jquery - 为什么在 Django 中只加载静态文件夹的文件?
- javascript - 如何在子目录中使用 webpack 导入加载?
- python - 如何用 Spark python 对 CSV 文件列求和
- unix - 如何在 Unix 中跟踪该特定进程的进程时间和磁盘使用情况?