| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- package com.poyee.dataSource;
- import org.apache.ibatis.session.SqlSessionFactory;
- import org.mybatis.spring.SqlSessionFactoryBean;
- import org.mybatis.spring.SqlSessionTemplate;
- import org.mybatis.spring.annotation.MapperScan;
- import org.springframework.beans.factory.annotation.Qualifier;
- 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.support.PathMatchingResourcePatternResolver;
- import javax.sql.DataSource;
- */
- /**
- * 主数据源配置
- *//*
- //@Configuration
- //@MapperScan(basePackages = {"com.poyee"}, sqlSessionFactoryRef = "masterSqlSessionFactory")
- public class MasterDataSourceConfig {
- */
- /**
- * @return
- *//*
- // @Bean(name = "masterDataSource")
- // @Primary
- // @ConfigurationProperties(prefix = "spring.datasource.master")
- public DataSource masterDataSource() {
- return DataSourceBuilder.create()
- .build();
- }
- */
- /**
- * @param masterDataSource
- * @return
- * @throws Exception
- *//*
- // @Bean(name = "masterSqlSessionFactory")
- // @Primary
- public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource) throws Exception {
- SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
- bean.setDataSource(masterDataSource);
- bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml"));
- return bean.getObject();
- }
- */
- /**
- * @param sqlSessionFactory
- * @return
- *//*
- // @Bean(name = "masterSqlSessionTemplate")
- // @Primary
- public SqlSessionTemplate masterSqlSessionTemplate(@Qualifier("masterSqlSessionFactory") SqlSessionFactory sqlSessionFactory) {
- return new SqlSessionTemplate(sqlSessionFactory);
- }
- }
- */
|