package com.hx.other.service.config;
|
|
import com.alibaba.druid.pool.DruidDataSource;
|
import com.github.pagehelper.PageInterceptor;
|
import org.apache.ibatis.plugin.Interceptor;
|
import org.apache.ibatis.session.SqlSessionFactory;
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Primary;
|
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
|
import javax.sql.DataSource;
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.List;
|
import java.util.Properties;
|
|
/**
|
* 数据源配置
|
* @Author: cmg
|
* @Date: 2023/5/5 10:56
|
*/
|
@Configuration
|
public class DataSourceConfig {
|
|
@Value("${mybatis.mapperLocations}")
|
private String writeMapperLocatioin;
|
|
@Bean(name = "readDataSource")
|
@Qualifier("readDataSource")
|
@ConfigurationProperties(prefix = "spring.datasource.read")
|
public DataSource readDataSource()
|
{
|
return DataSourceBuilder.create().build();
|
}
|
|
@Bean(name = "writeDataSource")
|
@Qualifier("writeDataSource")
|
@ConfigurationProperties(prefix = "spring.datasource.write")
|
@Primary
|
public DataSource writeDataSource()
|
{
|
return new DruidDataSource();
|
}
|
}
|