zoukankan      html  css  js  c++  java
  • Spring Boot 整合 SardingSphere (单表访问以及分库分表)

    Tips:

    • 其他代码 链接:https://www.cnblogs.com/yi1036943655/p/15700170.html
    • 在实际的项目里,不可能项目只有分库分表的表,肯定是带有不分库分表的表,当我学习SardingSphere的时候,我就在想这东西怎么配置,查阅过各种文章。总结就是在添加个数据源,无需额外配置。把不分库不分表的表,都放到这个数据源里。
    • 写的不一定正确,大佬勿喷,如果有更高效的方法,请指教

    application.properties

    spring.shardingsphere.datasource.names=sharding,sharding0,sharding1
    
    # 第零个数据库
    spring.shardingsphere.datasource.sharding.type=com.zaxxer.hikari.HikariDataSource
    spring.shardingsphere.datasource.sharding.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.shardingsphere.datasource.sharding.jdbc-url=jdbc:mysql://localhost:3306/sharding0?serverTimezone=GMT%2B8&useSSL=false
    spring.shardingsphere.datasource.sharding.username=root
    spring.shardingsphere.datasource.sharding.password=root
    
    # 第一个数据库
    spring.shardingsphere.datasource.sharding0.type=com.zaxxer.hikari.HikariDataSource
    spring.shardingsphere.datasource.sharding0.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.shardingsphere.datasource.sharding0.jdbc-url=jdbc:mysql://localhost:3306/sharding0?serverTimezone=GMT%2B8&useSSL=false
    spring.shardingsphere.datasource.sharding0.username=root
    spring.shardingsphere.datasource.sharding0.password=root
    
    # 第二个数据库
    spring.shardingsphere.datasource.sharding1.type=com.zaxxer.hikari.HikariDataSource
    spring.shardingsphere.datasource.sharding1.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.shardingsphere.datasource.sharding1.jdbc-url=jdbc:mysql://localhost:3306/sharding1?serverTimezone=GMT%2B8&useSSL=false
    spring.shardingsphere.datasource.sharding1.username=root
    spring.shardingsphere.datasource.sharding1.password=root
  • 相关阅读:
    python 爬虫数据处理字符串时间转换格式方法
    python 爬虫时间数据-时间格式转换
    python 爬虫数据时间转换格式
    python 爬虫newspaper3k 新闻爬去方法 利用第三方库
    python 三方库
    python 26个技巧
    python 爬虫第三方库
    python 爬虫数据准换时间格式
    python cookies提取——从字符串到字典(一行Python代码)
    python scrapy 把cookie并转化为字典的形式
  • 原文地址:https://www.cnblogs.com/yi1036943655/p/15734158.html
Copyright © 2011-2022 走看看