在没有@Inject的Scala中读取播放配置(2.6.5) [英] Reading Configuration in Play (2.6.5) with Scala without @Inject

查看:76
本文介绍了在没有@Inject的Scala中读取播放配置(2.6.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Scala中使用Play 2.6.5.在大多数情况下,从配置中读取内容都可以与注入配置一起使用.

I'm using Play 2.6.5 with Scala. Most of the times reading from the configuration works with injecting the configuration.

在某些部分中,将类纳入注入范围太困难了.

In some parts it would be too difficult to get a class into injection scope.

是否有一种无需注入即可获取配置对象的方法?

Is there a way to get the configuration object without injection?

推荐答案

您可以使用ConfigFactory->

You can use ConfigFactory ->

ConfigFactory.load().getString("db.url")

相同的导入->

import com.typesafe.config.ConfigFactory

这篇关于在没有@Inject的Scala中读取播放配置(2.6.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆