赞
踩
## mysql
spring.datasource.mysql.jdbc-url=jdbc:mysql://47.242.248.80:3306/alert_console?userUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.mysql.username=root
spring.datasource.mysql.password=mmt123456
spring.datasource.mysql.driver-class-name=com.mysql.cj.jdbc.Driver
## starrocks
spring.datasource.starrocks.jdbc-url=jdbc:mysql://172.16.3.134:9030/tracelog?userUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.starrocks.username=trace
spring.datasource.starrocks.password=123456
spring.datasource.starrocks.driver-class-name=com.mysql.cj.jdbc.Driver
@Configuration
public class DataSourceConfig {
@Bean(name = "mysql")
@ConfigurationProperties(prefix = "spring.datasource.mysql")
public DataSource mysqlDbDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "starRocks")
@ConfigurationProperties(prefix = "spring.datasource.starrocks")
public DataSource starRocksDbDataSource() {
return DataSourceBuilder.create().build();
}
}
@Configuration @MapperScan(basePackages = {"cn.wangoon.fd.tracking.management.console.mybatis.mapper.mysql"}, sqlSessionFactoryRef = "sqlSessionFactoryForMysql") public class MysqlConfig { @Resource @Qualifier("mysql") private DataSource mysqlDataSource; @Bean public SqlSessionFactory sqlSessionFactoryForMysql() throws Exception { SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); factoryBean.setDataSource(mysqlDataSource); // factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/db1/*.xml")); return factoryBean.getObject(); } @Bean public SqlSessionTemplate sqlSessionTemplateForMysql() throws Exception { return new SqlSessionTemplate(sqlSessionFactoryForMysql()); } }
@Configuration @MapperScan(basePackages = {"cn.wangoon.fd.tracking.management.console.mybatis.mapper.starrocks"}, sqlSessionFactoryRef = "sqlSessionFactoryForStarRocks") public class StarRocksConfig { @Resource @Qualifier("starRocks") private DataSource starRocksDataSource; @Bean public SqlSessionFactory sqlSessionFactoryForStarRocks() throws Exception { SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); factoryBean.setDataSource(starRocksDataSource); // factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/db2/*.xml")); return factoryBean.getObject(); } @Bean public SqlSessionTemplate sqlSessionTemplateForStarRocks() throws Exception { return new SqlSessionTemplate(sqlSessionFactoryForStarRocks()); } } rows Exception { return new SqlSessionTemplate(sqlSessionFactoryForStarRocks()); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。