0

I am using the slick of alpakka to config the database. I want to configure the slick config in runtime, for example:

For slick.jdbc.PostgresProfile$ section, how to put "$" in the config?



s"""
       |config {
       |  profile = "slick.jdbc.PostgresProfile$"
       |  db {
       |    dataSourceClass = "slick.jdbc.DriverDataSource"
       |    properties = {
       |      driver = "org.postgresql.Driver"
       |      url = "${dbUrl}"
       |      user = "${dbUser}"
       |      password = "${dbPassword}"
       |    }
       |  }
       |}
       |
     """.stripMargin


Jeffrey Chung
  • 19,319
  • 8
  • 34
  • 54
Tomia Wong
  • 37
  • 5
  • Note that this is not about syntax of the config file, it is about syntax of Scala formatting strings - the `$$` escape in the accepted answer is a Scala thing. In HOCON, which I believe this config file is written in, `$`s should be escaped with quotes (i.e. `key = "${some_value}"` will escape the substitution, while `key = ${some_value}` will perform it). – Vladimir Matveev Feb 20 '20 at 00:38
  • Yes. In my scenario, "slick.jdbc.PostgresProfile$" is a class name. – Tomia Wong Feb 20 '20 at 00:54

1 Answers1

3

Try

profile = "slick.jdbc.PostgresProfile$$"

YouXiang-Wang
  • 1,119
  • 6
  • 15