Skip to content

Instantly share code, notes, and snippets.

@ygreyeb
ygreyeb / MultiDataSourceConfig.java
Last active June 15, 2023 16:13
Configuration class to register and retrieve multiple data sources from Spring Boot application properties
package org.example;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;