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:
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?
One Solution collect form web for “Java + Docker: Different datasource url”
Yes you can. You will find everything you want to know here: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html