- application-dev.yml中配置文件如下:主要配置了主库和从库 直接看代码。
遇到的问题:1、 eclipse、idea中启动均正常。打成jar启动就报错。
解决办法:因为Mybatis无法扫描到xxxxMapper.xml中定义的别名。必须设置一下bean.setVfs(SpringBootVFS.class);
spring:
thymeleaf:
cache: false
datasource:
#主数据库
master:
continueOnError: true
type: com.alibaba.druid.pool.DruidDataSource
#主库URL
url: jdbc:mysql://localhost/master_db?useSSL=false
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
#从库
slaver:
continueOnError: true
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://localhost/slaver?useSSL=false
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
initialSize: 5
minIdle: 5
maxActive: 20
maxWait: 60000
timeBetweenEvictionRunsMillis: 60000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true