prabin b
prabin b

Reputation: 13

How can we dynamically set db.default.url in application.conf file?

I have a host name and a port, set in env variable and I want my db.default.url to be like this,

db.default.url="jdbc:mysql://${DB_PORT_3306_TCP_HOST}:${DB_PORT_3306_TCP_PORT}/database_name"

But this doesn't workout.

Upvotes: 1

Views: 434

Answers (1)

Kris
Kris

Reputation: 4823

I've never tried it myself but I guess it should look like this in the application.conf:

db.default.url="jdbc:mysql://"${host}":"${port}"/database_name"

And you'd start your project with something like this:

/path/to/bin/<project-name> -Dport=1234 -Dhost=127.0.0.1

You can learn a lot about the schema of Play's config from this doc.

Upvotes: 2

Related Questions