How to connect an H2 database and a PostgreSQL (Docker) database with Flyway versioning in Java using Spring Boot and IntelliJ
14:27 12 May 2026

I’m working on a Java project for my portfolio. Right now, I’m trying to connect my PostgreSQL database (running in Docker)—which will store the project’s “real” data—to an H2 database with in-memory storage for testing purposes, both using Flyway for versioning. However, I haven’t been able to find any information on how to make this connection or how the structure itself works to run and set up the .gitignore file. I’m currently trying to figure this out, so if anyone knows anything about it and can help me, I’d really appreciate it!!

java spring postgresql spring-boot flyway