1、使用mybatis-plus自身的查詢構造去,只需要在全局配置中添加如下配置
mybatis-plus:
mapper-locations: classpath:mappers/*Mapper.xml # mapper映射文件
global-config:
db-config:
table-prefix: tr_
2、自定義sql語句中添加表名前綴
在yml文件中添加如下配置
mybatis-plus:
mapper-locations: classpath:mappers/*Mapper.xml # mapper映射文件
global-config:
db-config:
table-prefix: tr_
configuration-properties:
prefix: tr_ # 自定義sql中表名帶前綴
然後在自定義sql語句如下
select * from ${prefix}user
編譯後的sql語句
select * from tr_user
mybaits-plus功能還是很強大的,官網地址:https://mp.baomidou.com/guide/