本文整理汇总了Scala中com.typesafe.config.ConfigParseOptions类的典型用法代码示例。如果您正苦于以下问题:Scala ConfigParseOptions类的具体用法?Scala ConfigParseOptions怎么用?Scala ConfigParseOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigParseOptions类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: AppConfig
//设置package包名称以及导入依赖的类
package au.csiro.data61.magda
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigParseOptions
import com.typesafe.config.ConfigResolveOptions
object AppConfig {
def getEnv = if (System.getenv("SCALA_ENV") == null) "host" else System.getenv("SCALA_ENV")
def conf(envOption: Option[String] = None) = {
val env = envOption.getOrElse(getEnv)
val parseOptionsAllowMissing = ConfigParseOptions.defaults().setAllowMissing(true)
val parseOptionsForbidMissing = ConfigParseOptions.defaults().setAllowMissing(false)
val resolveOptions = ConfigResolveOptions.defaults().setAllowUnresolved(false)
val commonGeneralConf = ConfigFactory.parseResources("common.conf")
val commonEnvConf = ConfigFactory.parseResources("common-env-specific-config/" + env + ".conf")
val appConf = ConfigFactory.parseResources("application.conf")
val envConf = ConfigFactory.parseResources("env-specific-config/" + env + ".conf")
envConf.withFallback(appConf).withFallback(commonEnvConf).withFallback(commonGeneralConf).resolve(resolveOptions)
}
}
开发者ID:TerriaJS,项目名称:magda,代码行数:26,代码来源:AppConfig.scala
示例2:
//设置package包名称以及导入依赖的类
package com.pacbio.common.dependency
import java.io.{Reader, File}
import java.net.URL
import com.typesafe.config.{ConfigParseOptions, ConfigFactory, Config}
trait ConfigProvider {
val parseOptions: Singleton[ConfigParseOptions] = Singleton(ConfigParseOptions.defaults())
val config: Singleton[Config]
}
trait DefaultConfigProvider extends ConfigProvider {
override val config: Singleton[Config] = Singleton(() => ConfigFactory.load(parseOptions()))
}
trait FileConfigProvider extends ConfigProvider {
val configFile: Singleton[File]
override val config: Singleton[Config] =
Singleton(() => ConfigFactory.parseFile(configFile(), parseOptions()))
}
trait ReaderConfigProvider extends ConfigProvider {
val configReader: Singleton[Reader]
override val config: Singleton[Config] =
Singleton(() => ConfigFactory.parseReader(configReader(), parseOptions()))
}
trait URLConfigProvider extends ConfigProvider {
val configURL: Singleton[URL]
override val config: Singleton[Config] =
Singleton(() => ConfigFactory.parseURL(configURL(), parseOptions()))
}
trait StringConfigProvider extends ConfigProvider {
val configString: Singleton[String]
override val config: Singleton[Config] =
Singleton(() => ConfigFactory.parseString(configString(), parseOptions()))
}
开发者ID:PacificBiosciences,项目名称:smrtflow,代码行数:40,代码来源:ConfigProvider.scala
示例3: apply
//设置package包名称以及导入依赖的类
package rxthings.config
import java.net.URL
import akka.http.scaladsl.model.Uri
import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions, ConfigSyntax}
import com.typesafe.scalalogging.LazyLogging
import scala.concurrent.{ExecutionContext, Future}
def apply(host: String, port: Int = 8888, branch: String = "master"): CloudConfig = {
DefaultCloudConfig(Uri(s"http://$host:$port"), branch)
}
}
// default implementation of [[CloudConfig]]
private[config] case class DefaultCloudConfig(uri: Uri, branch: String) extends CloudConfig with LazyLogging {
val parseOptions = ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON)
def load(app: String, profile: String)(implicit ec: ExecutionContext): Future[Config] = {
val url = new URL(fulluri(app, profile).toString)
Future {
logger.debug(s"CloudConfig @ $url")
ConfigFactory.parseURL(url, parseOptions)
}
}
def fulluri(app: String, profile: String): Uri = {
val fullpath = uri.path / branch / s"$app-${resolveProfile(profile)}.json"
uri.withPath(fullpath)
}
// allows the profile to be overridden by env var
def resolveProfile(profile: String) = {
require(profile.nonEmpty, "profile cannot be empty")
sys.env.getOrElse(CloudConfig.profileEnvKey, profile)
}
}
开发者ID:jw3,项目名称:cloud-config,代码行数:40,代码来源:CloudConfig.scala
示例4: DbevolvConfiguration
//设置package包名称以及导入依赖的类
package com.mnubo.dbevolv
import java.io.File
import com.typesafe.config.{Config, ConfigFactory, ConfigParseOptions}
object DbevolvConfiguration {
def loadConfig(env: String = System.getenv("ENV")): Config = {
require(env != null && !env.trim.isEmpty, "You must provide an ENV environment variable for the configuration to pick the right properties.")
val generalConfig = ConfigFactory
.parseFile(new File("db.conf"))
.withFallback(ConfigFactory.load(ConfigParseOptions.defaults().setClassLoader(getClass.getClassLoader)))
def maybeConfig(path: String) =
if (generalConfig.hasPath(path)) Some(generalConfig.getConfig(path)) else None
List(Some(ConfigFactory.defaultOverrides()), maybeConfig(env), maybeConfig("default"), Some(generalConfig))
.flatten
.reduce(_ withFallback _)
}
}
开发者ID:mnubo,项目名称:dbevolv,代码行数:23,代码来源:DbevolvConfiguration.scala
示例5: UtilityServiceSlice
//设置package包名称以及导入依赖的类
package com.microworkflow.rest
import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpResponse}
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.Directives._
import com.typesafe.config.{ConfigFactory, ConfigParseOptions, ConfigRenderOptions, ConfigSyntax}
//noinspection TypeAnnotation
class UtilityServiceSlice {
val options = ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)
val intentSchema = ConfigFactory.parseResources("intent-schema.json", options)
val routes: Route = {
path("info") {
get {
complete(HttpResponse(entity = HttpEntity(ContentTypes.`application/json`, buildinfo.BuildInfo.toJson)))
}
} ~ path("intent-schema") {
pathEnd {
get {
complete {
HttpResponse(entity = HttpEntity(ContentTypes.`application/json`, intentSchema.root().render(ConfigRenderOptions.concise())))
}
}
}
}
}
}
开发者ID:polymorphic,项目名称:shakey,代码行数:30,代码来源:UtilityServiceSlice.scala
注:本文中的com.typesafe.config.ConfigParseOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论