lijie 4fce3ed5e7 升级:调整mvn版本号为1.1.0 | vor 2 Jahren | |
---|---|---|
.. | ||
src | vor 3 Jahren | |
README.md | vor 3 Jahren | |
pom.xml | vor 2 Jahren | |
pom.xml.versionsBackup | vor 2 Jahren |
mybatis-plus封装
多数据源
配置文件示例 ``` spring: datasource: druid: stat-view-servlet:
enabled: true
loginUsername: admin
loginPassword: 123456
dynamic: druid: #以下是支持的全局默认值
initial-size:
max-active:
min-idle:
max-wait:
time-between-eviction-runs-millis:
time-between-log-stats-millis:
stat-sqlmax-size:
min-evictable-idle-time-millis:
max-evictable-idle-time-millis:
test-while-idle:
test-on-borrow:
test-on-return:
validation-query:
validation-query-timeout:
use-global-datasource-stat:
async-init:
clear-filters-enable:
reset-stat-enable:
not-full-timeout-retry-count:
max-wait-thread-count:
fail-fast:
phyTimeout-millis:
keep-alive:
pool-prepared-statements:
init-variants:
init-global-variants:
use-unfair-lock:
kill-when-socket-read-timeout:
connection-properties:
max-pool-prepared-statement-per-connection-size:
init-connection-sqls:
share-prepared-statements:
connection-errorretry-attempts:
break-after-acquire-failure:
filters: stat,wall # 注意这个值和druid原生不一致,默认启动了stat,wall
wall:
noneBaseStatementAllow:
callAllow:
selectAllow:
selectIntoAllow:
selectIntoOutfileAllow:
selectWhereAlwayTrueCheck:
selectHavingAlwayTrueCheck:
selectUnionCheck:
selectMinusCheck:
selectExceptCheck:
selectIntersectCheck:
createTableAllow:
dropTableAllow:
alterTableAllow:
renameTableAllow:
hintAllow:
lockTableAllow:
startTransactionAllow:
blockAllow:
conditionAndAlwayTrueAllow:
conditionAndAlwayFalseAllow:
conditionDoubleConstAllow:
conditionLikeTrueAllow:
selectAllColumnAllow:
deleteAllow:
deleteWhereAlwayTrueCheck:
deleteWhereNoneCheck:
updateAllow:
updateWhereAlayTrueCheck:
updateWhereNoneCheck:
insertAllow:
mergeAllow:
minusAllow:
intersectAllow:
replaceAllow:
setAllow:
commitAllow:
rollbackAllow:
useAllow:
multiStatementAllow:
truncateAllow:
commentAllow:
strictSyntaxCheck:
constArithmeticAllow:
limitZeroAllow:
describeAllow:
showAllow:
schemaCheck:
tableCheck:
functionCheck:
objectCheck:
variantCheck:
mustParameterized:
doPrivilegedAllow:
dir:
tenantTablePattern:
tenantColumn:
wrapAllow:
metadataAllow:
conditionOpXorAllow:
conditionOpBitwseAllow:
caseConditionConstAllow:
completeInsertValuesCheck:
insertValuesCheckSize:
selectLimit:
stat:
merge-sql:
log-slow-sql:
slow-sql-millis:
datasource:
master:
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://xx.xx.xx.xx:3306/dynamic?characterEncoding=utf8&useSSL=false
druid: # 以下是独立参数,每个库可以重新设置
initial-size:
validation-query: select 1 FROM DUAL #比如oracle就需要重新设置这个
public-key: #(非全局参数)设置即表示启用加密,底层会自动帮你配置相关的连接参数和filter,推荐使用本项目自带的加密方法。
预置建库脚本
* [参考配置](https://github.com/dynamic-datasource/dynamic-datasource-doc/blob/master/docs/guide/advance/Init-Schema-Data.md)
* 脚本文件放在resources目录,在默认数据源中增加配置:
spring:
datasource:
dynamic:
primary: order
datasource:
order:
# 基础配置省略...
schema: db/order/schema.sql # 配置则生效,自动初始化表结构。
data: db/order/data.sql # 配置则生效,自动初始化数据。
continue-on-error: true # 默认true,初始化失败是否继续
separator: ";" # sql默认分号分隔符,一般无需更改
* 注意事项:
- schema: 建立连接时会执行,因此建表应使用CREATE TABLE IF NOT EXISTS确保不会重复创建。
- data: 建立连接时会执行,应确保数据不会重复插入。
树型内部码工具
* 可对实现ITreeEntity的model自动生成innerCode内部码。
自定义DB数据格式转换器
* 放入此目录中即可: com.persagy.**.typehandler
* json类型自动转换,需要配置@TableName(value = "tableName", autoResultMap = true)和字段@TableField(typeHandler = JacksonTypeHandler.class)
最新变化
---------------
注意事项
---------------
字符集配置:DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
* 在建库语句中标记字符集,代码中的建表语句不出现字符集相关的语句(导出时如果有则手动清除)。
* 字符集不一致修复sql:
-- 数据库字符集修改
ALTER DATABASE ${schema}
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
-- 表字符集修改
SELECT CONCAT('ALTER TABLE ', TABLE_NAME, ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;')
FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${schema}';
-- 拷贝查询到的结果并执行即可
```