转载请注明出处!
yml文件:这个是配置是别人写的,我只是把数据源改了,贴这个的原因是因为在数据源切换的是后token出问题了,原因就在这个配置里
spring:
datasource:
druid:
# 数据库 1
db1:
url: jdbc:sqlserver://localhost:1433;DatabaseName=db1
username: sa
password: 123
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
initial-size: 1
max-active: 20
min-idle: 1
# 数据库 2
db2:
url: jdbc:sqlserver://localhost:1433;DatabaseName=db2
username: sa
password: 123
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
initialSize: 1
minIdle: 1
maxActive: 20
mybatis:
type-aliases-package: com.demo.entity
mapper-locations: classpath:/com/demo/mapper/xml/*.xml
configuration:
callSettersOnNulls: true
map-underscore-to-camel-case: true
default-fetch-size: 100
default-statement-timeout: 3000
mybatis-plus:
# 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
# 如果是放在resource目录 classpath:/mapper/*Mapper.xml
mapper-locations: classpath:/com/demo/mapper/xml/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.demo.entity
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 0
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
db-column-underline: true
#刷新mapper 调试神器
refresh-mapper: true
#数据库大写下划线转换
capital-mode: true
# Sequence序列接口实现类配置
# key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
#逻辑删除配置(下面3个配置)
logic-delete-value: 1
logic-not-delete-value: 0
sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
#自定义填充策略接口实现
# meta-object-handler: com.baomidou.springboot.MyMetaObjectHandler
configuration:
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: