An example of Spring Boot, written in Kotlin, demonstrates how to use Hibernate with Kotlin as well as multiple datasources with the ability to create tables of the datasources and support for distributed transactions in multiple datasources.
To understand more about the project read the following tutorials,
- How to deal with Hibernate entities in Kotlin
- Spring Boot connect to multiple datasources
- Spring transaction with multiple datasources
- PostgreSQL integration tests using Testcontainers
First, start the databases (MySQL 8 and PostgreSQL 15) with docker-compose,
$ docker-compose up -dThen run the project using mvnw,
$ ./mvnw spring-boot:run -Dserver.port=8090 Lastly, open the browser and type http://localhost:8080/swagger-ui/index.html. You should see the Swagger interface to interact with the API.
To change the database configuration modify docker-compose.yml and if necessary application.properties.