application.yml中数据源配置:
#数据库连接 天气数据
spring:
datasource:
keshangjdbc:
url: jdbc:oracle:thin:@//IP:1565/ods
username:
password:
# driver-class-name: oracle.jdbc.driver.OracleDriver
#数据库连接 客商数据
weatherjdbc:
url: jdbc:oracle:thin:@//IP:1565/ods
username:
password:
# driver-class-name: oracle.jdbc.driver.OracleDriver
对每中链接写一个配置类,主要是通过aop的方式链接注入到SqlSessionTemplate中,
客商的配置类如下:
package com.neusoft.interf.dataSources;
import javax.sql.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 org.springframework.jdbc.datasource.DataSourceTransactionManager;
import com.alibaba.druid.pool.DruidDataSource;
/**
* @author
* @Time:2018年12月19日 上午11:08:35
* @version 1.0
*/
@Configuration
@MapperScan(basePackages = "com.neusoft.in