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 similar to the Typesafe Config library but other solutions are welcome too ! Is there a way to do something like below:
val hdfsConfig = ConfigFactory.load("my_path/hdfs.conf")
我想你想要的是:
val myCfg = ConfigFactory.parseFile(new File("my_path/hdfs.conf"))
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
val config = ConfigFactory.load("pathtoFile/FileName.propertes")
也有效。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.