puzhibing
2026-02-04 a7146e068f1b980a6dbe98cdb8d23eb07ba205b8
合并代码
2个文件已修改
47 ■■■■■ 已修改文件
xp-service/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/xp-vehicleConvoy/src/main/resources/bootstrap.yml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-service/pom.xml
@@ -51,6 +51,11 @@
            <artifactId>unified-verification</artifactId>
            <version>1.5.2-v2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-jdbc</artifactId>
            <version>5.5.2</version>
        </dependency>
    </dependencies>
</project>
xp-service/xp-vehicleConvoy/src/main/resources/bootstrap.yml
@@ -157,4 +157,44 @@
        file-extension: yml
        # 共享配置
        shared-configs:
          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
          - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
---
#shardingSphere-jdbc
databaseName: xprt_operation
#
mode:
  type: Standalone # 运行模式类型。可选配置:Standalone、Cluster
  repository:
    type: JDBC # 持久化仓库类型 单机版:JDBC  集群版:ZooKeeper
#    props: # 持久化仓库所需属性
#      namespace: governance # 注册中心命名空间
#      server-lists: localhost:2181 # 注册中心连接地址
#      retryIntervalMilliseconds: 500
#      timeToLiveSeconds: 60
dataSources: # 数据源配置,可配置多个
  xp_0: # 数据源名称
    dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.mysql.jdbc.Driver
    standardJdbcUrl: jdbc:mysql://192.168.110.34:3306/xprt_operation?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
    username: root
    password: 123456
# 分片规则
rules:
  - !SHARDING
    tables: # 数据分片规则配置
      xp_whitelist_operlog: # 逻辑表名称
        actualDataNodes: xp_${0}.xp_whitelist_operlog_${0..1} # 由数据源名 + 表名组成(参考 Inline 语法规则)
        tableStrategy: # 分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一
          standard:
            shardingColumn: operation_account_id
            shardingAlgorithmName: t_vehicle_convoy_inline
        keyGenerateStrategy: # 分布式序列策略
          column: id # 自增列名称,缺省表示不使用自增主键生成器
          keyGeneratorName: snowflake # 分布式序列算法名称
    shardingAlgorithms: # 分库算法
      t_vehicle_convoy_inline:  # 分库算法名称
        type: INLINE  # 分库算法类型
        props:  # 分库算法属性
          algorithm-expression: t_vehicle_convoy_${operation_account_id % 2}