messy messy - 4 days ago 5
Java Question

Java + Docker: Different datasource url

I'm working on a Spring Boot project which I want to run in a docker environment. The project is split up in different modules each having it's own Dockerfile so I'm using docker compose to combine these. I have one service for the db:

db:
image: postgres:9.5
ports:
- 5432:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
POSTGRES_DB: db1


The module which work with the db has the datasource set:
spring.datasource.url= jdbc:postgresql://db:5432/db1


The problem is that I have colleagues who do not want to run it in docker for performance reasons (Windows + Mac user). They rely on
spring.datasource.url= jdbc:postgresql://localhost:5432/db1
. Can I use different datasources depending on the environment the module is running?

Answer
Comments