2
votes

I am using scala typesafe config (version 1.2.1) in one of my projects to read the application.conf file, my project has dependency on multiple other projects and I create a jar with dependencies to run the dependency projects.

Problem - those projects also use typesafe and has application.conf files in top level directory and my maven jar with dependencies pick up only one application.conf in same classpath and drops rest of them (I tried using maven shade plugin to merge these conf files and I don't want to go that route). I am trying to place these application.conf files in packages, so they don't get overriden in jar with dependencies, but typesafe doesn't seem to recognize the files under a package name in resources directory, it can only find the conf file if placed under top level resources directory.

Is there a better solution to achieve this by using typesafe ? or I am open to using a totally different config library for scala if there is any.

1
If I understand well your question, you can use: ConfigFactory.parseFile(getClass.getClassLoader.getResource("yourApplication.conf")).faster2b
You are saying the conf file name can be <anything>.conf and not necessarily application.conf ? that sounds betterpbathala
yes, the conf file name can be <anything>.conffaster2b
I tried lot of things, but didn't try different name :D. Thanks for help.pbathala

1 Answers

0
votes

Given a file structure like this:

$tree src/main/resources/
 src/main/resources
 └── path
     └── to
         └── file
             └── xxx.conf

You can load the config with the following command:

val config = ConfigFactory.load("path/to/file/xxx.conf")