Last active
October 31, 2018 21:28
-
-
Save soujiro32167/177e88da1be273519216d3926e18149d to your computer and use it in GitHub Desktop.
TypeSafe config inclusion pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my { | |
b: "derp" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "include.conf" | |
my { | |
a: "herp" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.typesafe.config.Config; | |
import com.typesafe.config.ConfigFactory; | |
class Scratch { | |
public static void main(String[] args) { | |
Config config = ConfigFactory.load(); | |
System.out.println(config.getConfig("my")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Config(SimpleConfigObject({"a":"herp","b":"derp"})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -jar ... -Dconfig.file=main.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment