https://github.com/kasramp/spring-multiple-datasources
Spring example written in Kotlin demonstrates how to use mutiple datasources with the ability of creating tables of the datasources
https://github.com/kasramp/spring-multiple-datasources
hibernate-multitenant jpa jpa-hibernate kotlin kotlin-spring-boot spring-boot spring-boot-3 springboot3
Last synced: 2 months ago
JSON representation
Spring example written in Kotlin demonstrates how to use mutiple datasources with the ability of creating tables of the datasources
- Host: GitHub
- URL: https://github.com/kasramp/spring-multiple-datasources
- Owner: kasramp
- License: gpl-3.0
- Created: 2019-09-28T22:05:50.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-21T00:08:39.000Z (over 1 year ago)
- Last Synced: 2025-01-25T09:26:18.870Z (4 months ago)
- Topics: hibernate-multitenant, jpa, jpa-hibernate, kotlin, kotlin-spring-boot, spring-boot, spring-boot-3, springboot3
- Language: Kotlin
- Homepage: https://www.geekyhacker.com/spring-boot-connect-to-multiple-datasources/
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Spring Boot multiple datasources
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](https://www.geekyhacker.com/how-to-deal-with-hibernate-entities-in-kotlin/)
- [Spring Boot connect to multiple datasources](https://www.geekyhacker.com/spring-boot-connect-to-multiple-datasources/)
- [Spring transaction with multiple datasources](https://www.geekyhacker.com/spring-transaction-with-multiple-datasources/)
- [PostgreSQL integration tests using Testcontainers](https://www.geekyhacker.com/postgresql-integration-tests-using-testcontainers/)## How to run
First, start the databases (MySQL 8 and PostgreSQL 15) with `docker-compose`,
```bash
$ docker-compose up -d
```Then run the project using `mvnw`,
```bash
$ ./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.
## Tips
To change the database configuration modify `docker-compose.yml` and if necessary `application.properties`.