How to use system properties to substitute placeholders in Typesafe Config file?

前端 未结 1 1959
无人及你
无人及你 2021-02-07 06:58

I need to refer to java.io.tmpdir in my application.conf file

I printed content of my config with

val c = ConfigFactory.load()
System.e         


        
相关标签:
1条回答
  • 2021-02-07 07:20

    Forward references work fine; I believe the issue is just that you have the ${} syntax inside of quotes, so it doesn't have special meaning. Try it like this:

    url = "jdbc:h2:file:"${java.io.tmpdir}"/db;DB_CLOSE_DELAY=-1"
    

    (note that the ${} stuff is not quoted)

    In the HOCON format, anything that's valid JSON will be interpreted as it would be in JSON, so quoted strings for example don't have special syntax inside them, other than the escape sequences JSON supports.

    0 讨论(0)
提交回复
热议问题