Configure Multiple (Routing) Datasources in Spring Boot + Spring Data And Switch Them At Runtime

Опубликовано: 11 Март 2025
на канале: Cyecize
7,951
154

This video is about configuring Spring Data to work with multiple data sources and switch them using annotations. Also, I show how to make a given JPA Repository bound to just one data source.

Here's the code from the video:
https://github.com/Cyecize/Spring-Dat...

I am using My SQL and Microsoft SQL Server in order to show how easy it really is to have them running together in one app.

An issue with dialects was found after I recorded the video.
This commit fixed the issue:
https://github.com/Cyecize/Spring-Dat...
If you only want to use one type of SQL Server, then this will not affect you!

Timecodes
0:00 - Intro
0:22 - Example #1 & Project Overview
3:07 - Build Data Sources
9:29 - Logic for Routing Data Sources
21:40 - Testing Example #1
25:43 - Example With Nested Transactions
31:16 - Example #2 Overview
34:22 - Logic for Routing JPA Repository
46:50 - Testing Example #2