Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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")
like image 227
RAbraham Avatar asked Aug 12 '13 19:08

RAbraham


3 Answers

I think what you want is:

val myCfg =  ConfigFactory.parseFile(new File("my_path/hdfs.conf"))
like image 181
cmbaxter Avatar answered Nov 20 '22 17:11

cmbaxter


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

like image 23
tcat Avatar answered Nov 20 '22 16:11

tcat


val config = ConfigFactory.load("pathtoFile/FileName.propertes") 

works, too.

like image 5
Suresh Avatar answered Nov 20 '22 17:11

Suresh