//package com.docus.server.collection.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//
//@Configuration
//@MapperScan(basePackages = com.docus.server.collection.config.DbSqlserverConfig.PACKAGE, sqlSessionFactoryRef = "dbsqlserverSqlSessionFactory")
//@EnableConfigurationProperties(MybatisPlusProperties.class)
//public class DbSqlserverConfig {
//    // 这里一定要指定精准  否则后果不堪设想
//    static final String PACKAGE = "com.docus.server.collection.infrastructure.dao.sqlserver";
//    static final String MAPPER_LOCATION = "classpath:sqlserver/*.xml";
//
//    @Bean(name = "dbsqlserverDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.sqlserver-docus")
//    public DataSource secondDataSource(){
//        return new DruidDataSource();
//    }
//
//    /*注入事务*/
//    @Bean(name = "dbsqlserverTransactionManager")
//    public DataSourceTransactionManager secondTransactionManager() {
//        return new DataSourceTransactionManager(secondDataSource());
//    }
//
//    @Bean(name = "dbsqlserverSqlSessionFactory")
//    public SqlSessionFactory secondSqlSessionFactory(@Qualifier("dbsqlserverDataSource") DataSource secondDataSource)
//            throws Exception {
//        final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//        sessionFactory.setDataSource(secondDataSource);
//        sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
//                .getResources(com.docus.server.collection.config.DbSqlserverConfig.MAPPER_LOCATION));
//        return sessionFactory.getObject();
//    }
//
//}
