SpringBoot如何配置數(shù)據(jù)庫主從shardingsphere
更新時間:2024年04月19日 15:27:59 作者:偷代碼的貓
這篇文章主要介紹了SpringBoot如何配置數(shù)據(jù)庫主從shardingsphere問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
SpringBoot配置數(shù)據(jù)庫主從shardingsphere
spring:
shardingsphere:
props.sql.show: true
datasource:
names: master,slave1
master:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.1.101:3306/user?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true
username: admin
password: 123456
minimum-idle: 10
maximum-pool-size: 20
idle-timeout: 300000
max-lifetime: 900000
connection-timeout: 30000
connection-test-query: SELECT 1
slave1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://192.168.1.102:3306/user?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true
username: admin
password: 123456
minimum-idle: 10
maximum-pool-size: 20
idle-timeout: 300000
max-lifetime: 900000
connection-timeout: 30000
connection-test-query: SELECT 1
masterslave:
name: us
load-balance-algorithm-type: ROUND_ROBIN
master-data-source-name: master
slave-data-source-names:
- slave1
- master
jackson:
serialization:
indent_output: true
main:
allow-bean-definition-overriding: true1、SQL是否打印顯示
props.sql.show: true
2、數(shù)據(jù)源名稱
names: master,slave1
3、負載均衡算法
load-balance-algorithm-type: ROUND_ROBIN ROUND_ROBIN:輪詢 RANDOM:隨機
4、主數(shù)據(jù)源名稱
master-data-source-name: master
5、從數(shù)據(jù)源名稱
slave-data-source-names:
- slave1
- master總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Mybatis實現(xiàn)動態(tài)拼接SQL的實踐指南
這篇文章主要為大家詳細介紹了Mybatis實現(xiàn)動態(tài)拼接SQL的相關(guān)知識,文中的示例代碼講解詳細, 感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2025-11-11
把Jar文件轉(zhuǎn)成exe安裝文件的實現(xiàn)方法
下面小編就為大家?guī)硪黄袹ar文件轉(zhuǎn)成exe安裝文件的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11
SpringBoot創(chuàng)建JSP登錄頁面功能實例代碼
這篇文章主要介紹了SpringBoot創(chuàng)建JSP登錄頁面功能實例代碼,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-04-04

