G V
G V

Reputation: 85

switching one database platform to another database in spring boot

I'm working in a application which uses the database POSTGRESQL. As per recent recommendations, the same application pointed to MYSQL by changing data source in application.properties. So, this activity may repeat in future also.

I don't want to change application.properties every time. I need to switch POSTGRES to MYSQL. In Hibernate, we can achieve this by configuring two mapping files. Like this, can we achieve this in spring boot?

Any Suggestions or examples are appreciated

Upvotes: 0

Views: 1044

Answers (1)

Wim Deblauwe
Wim Deblauwe

Reputation: 26858

You can use profiles in Spring for this.

Create a application-postgresql.properties file and a application-mysql.properties file, each with the corresponding JDBC url. Then start your application with either the postgresql or mysql profile.

See https://reflectoring.io/spring-boot-profiles/ for more info.

Upvotes: 2

Related Questions