#mysql数据库
spring:
datasource:
repair:
jdbc-url: jdbc:mysql://121.41.**.**:3306/******?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
username: "******"
password: "@******!"
driver-class-name: com.mysql.cj.jdbc.Driver
bi:
jdbc-url: jdbc:mysql://47.97.**.**:3306/******?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
username: "******"
password: "******"
driver-class-name: com.mysql.cj.jdbc.Driver
csapp:
jdbc-url: jdbc:mysql://13.56.**.**:3306/******?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
username: "******"
password: "******"
driver-class-name: com.mysql.cj.jdbc.Driver
###数据源的其他配置
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
useGlobalDataSourceStat: true
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
@Configuration
@MapperScan(basePackages = "com.cupshe.dc.service.mapper.bi", sqlSessionTemplateRef = "biSqlSessionTemplate")
public class DataSourceBiConfig {
@Bean
@ConfigurationProperties(prefix = "spring.datasource.bi")
public DataSource biDataSource() {
return DataSourceBuilder.create().build();
}
@Bean
public SqlSessionFactory biSqlSessionFactory(@Qualifier("biDataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mybatis/mapper/bi/*/*.xml"));
return bean.getObject();
}
@Bean
public DataSourceTransactionManager biTransactionManager(@Qualifier("biDataSource") DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
public SqlSessionTemplate biSqlSessionTemplate(@Qualifier("biSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
}