XoXo
XoXo

Reputation: 1599

provide external config files in scala application

In IntelliJ, I exported a scala/akka project using "dist". That ends in a zip file, under

foo\target\universal\foo-1.0.0.zip

When I unzip the file, I get following directory structure:

D:.
├───bin
│       foo
│       foo.bat
│
└───lib
        a.jar
        b.jar
        com.foo.jar
        ...
        x.jar

In command line, I'm trying to run the foo.bat, but I'd like to provide external config files.

I'd like to use e.g. application.conf.prod and logback.xml.prod, to override the application.conf and logback.xml files in the com.foo.jar file

I'm using the following versions (copying part of build.sbt):

version := "1.0.0"
scalaVersion := "2.11.8"

"com.typesafe.akka" %% "akka-actor" % "2.4.9"
"com.typesafe.akka" %% "akka-slf4j" % "2.4.9"
"ch.qos.logback" % "logback-classic" % "1.1.6"
"org.apache.kafka" % "kafka-clients" % "0.10.0.0"

Is there a way to do it?

Thanks

Upvotes: 0

Views: 1857

Answers (1)

hveiga
hveiga

Reputation: 6915

I think you can do this by passing arguments when running your jvm application.

  • For the application.conf you can use -Dconfig.file=/your/path/application.conf

  • For LogBack you can use -Dlogback.configurationFile="/your/path/logback.xml"

Upvotes: 3

Related Questions