SpringBoot3整合Druid的多数据源配置
【代码】【无标题】
·
SpringBoot3整合Druid的多数据源配置
pom.xml
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
<version>1.2.25</version>
</dependency>
application.yml
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/postgres?socketTimeout=5
username: postgres
password: postgres
druid: #这里为每个数据源单独配置
initial-size: 5
max-active: 20
slave_1:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/postgres
username: postgres
password: postgres
druid: #这里开启可视化控制台页面
stat-view-servlet:
enabled: true
参考:
[1]: Spring Boot整合Druid:轻松实现SQL监控和数据库密码加密
[2]: Druid配置详解,新手必须读
[3]: SpringBoot【十一】mybatis-plus实现多数据源配置,开箱即用!
[4]: mvnrepository
DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐

所有评论(0)