Typesafe config: Load additional config from path external to packaged scala application

前端 未结 3 1925
后悔当初
后悔当初 2021-01-30 16:13

My scala application will be packaged into a jar. When I run my app, it needs to read an additional config file stored externally to my app jar. I am looking for functionality s

相关标签:
3条回答
  • 2021-01-30 16:52

    If your external configuration is to add to or override configuration parameters from standard locations, you can do the following:

    val baseConfig = ConfigFactory.load()
    val config = ConfigFactory.parseFile(yourFile).withFallback(baseConfig)
    

    where yourFile is a java.io.File Documentation reference here

    0 讨论(0)
  • 2021-01-30 17:04
    val config = ConfigFactory.load("pathtoFile/FileName.propertes") 
    

    works, too.

    0 讨论(0)
  • 2021-01-30 17:10

    I think what you want is:

    val myCfg =  ConfigFactory.parseFile(new File("my_path/hdfs.conf"))
    
    0 讨论(0)
提交回复
热议问题