1.修改配置文件
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
click:
# 从数据源开关/默认关闭
driverClassName: ru.yandex.clickhouse.ClickHouseDriver
url: jdbc:clickhouse://127.0.0.1:8123/test
username: root
password: 123456
initialSize: 10
maxActive: 100
minIdle: 10
maxWait: 6000
mysql:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
2.修改主运行类添加注解
@Import({DynamicDataSourceConfig.class})
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class, DataSourceHealthContributorAutoConfiguration.class})
3.创建相关配置文件