feat: 读写分离

This commit is contained in:
胥员员
2022-11-08 15:30:22 +08:00
parent ca6e8eff22
commit 8b924446ed
6 changed files with 96 additions and 10 deletions

View File

@@ -35,6 +35,11 @@ spring:
inline:
sharding-column: user_id
algorithm-expression: orders_${user_id % 8}
# 读写分离配置,对应 YamlMasterSlaveRuleConfiguration 配置类
masterslave:
name: ms # 名字,任意,需要保证唯一
master-data-source-name: db0 # 主库数据源
slave-data-source-names: db1 # 从库数据源
# 拓展属性配置
props:
sql:
@@ -43,6 +48,14 @@ server:
port: 7529
servlet:
context-path: /api
mybatis:
mapper-locations: classpath*:src/main/resources/mapper/*.xml
type-aliases-package: com.yupi.project.model.entity
# mybatis-plus 配置内容
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: none # 虽然 MyBatis Plus 也提供 ID 生成策略,但是还是使用 Sharding-JDBC 的
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: com.yupi.project.model.entity