a.moussa
a.moussa

Reputation: 3287

read a scala conf file from a maven jar

I would like to read two scala conf file from a maven jar named myconfiguration1.conf and myconfiguration2.conf:

driver= oracle.jdbc.driver.OracleDriver
user = myUser
password = pass
url = myUrl
table = my_table

before generate my jar, i used a line like this:

val myconfig1 = ConfigFactory.parseFile(new File("./my-project/src/main/resources/myconfiguration1.conf")) 
val myconfig2 = ConfigFactory.parseFile(new File("./my-project/src/main/resources/myconfiguration2.conf")) 

Inside my jar, i have a tree like this

my-project-0.0.1.jar
      |___ myconfiguration1.conf
      |___ myconfiguration2.conf

Do you have any idea since the two lines don't work with the jar file.

Upvotes: 1

Views: 396

Answers (1)

chengpohi
chengpohi

Reputation: 14217

Seems you are using typesafe config to load the conf file, you can directly use ConfigFactory.load("myconfiguration1.conf") and ConfigFactory.load("myconfiguration2.conf") to load the classpath configuration file.

public static load(java.lang.String resourceBasename)

Upvotes: 3

Related Questions