io.smilego.tenant.persistence.datasource.MasterDataSourceConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-spring-boot-starter Show documentation
Show all versions of multi-tenant-spring-boot-starter Show documentation
A application used as an example on how to set up pushing
its components to the Central Repository.
package io.smilego.tenant.persistence.datasource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
@Component
@Configuration
@ConditionalOnMissingBean(DataSource.class)
public class MasterDataSourceConfiguration {
@Bean
@ConfigurationProperties("multitenancy.master.datasource")
@Primary
public DataSourceProperties masterDataSourceProperties(){
return new DataSourceProperties();
}
@Bean
@ConfigurationProperties("multitenancy.master.datasource.hikari")
@Primary
public DataSource masterDataSource(){
HikariDataSource dataSource = masterDataSourceProperties()
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
dataSource.setPoolName("masterDataSource");
return dataSource;
}
@Bean
@ConfigurationProperties("multitenancy.tenant.datasource.hikari")
public HikariConfig tenantHikariConfig(){
return new HikariConfig();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy