pom引入
<mybatis.version>2.3.2</mybatis.version><druid.version>1.1.23</druid.version><!--数据库--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>${mybatis.version}</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><!-- 数据库连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>${druid.version}</version></dependency>
设置 DruidConfig 配置
spring:datasource:type: com.alibaba.druid.pool.DruidDataSource #引入druid数据源#数据源基本信息,也可放在druid下url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTCusername: rootpassword: 123456driver-class-name: com.mysql.cj.jdbc.Driverdruid:#SpringBoot因为默认是hikari数据源所以对于其他数据源默认是不注入这些属性的,需要手动配置#druid数据源专有配置initialSize: 5minIdle: 5maxActive: 20maxWait: 600000# 主要配置以上几个即可timeBetweenEvictionRunsMillis: 600000minEvictableIdleTimeMillis: 300000validationQuery: SELECT 1 FROM DUALtestWhileIdle: truetestOnBorrow: falsetestOnReturn: falsepoolPreparedStatements: true
配置 mybatis信息 和日志信息打印
# 方法一:只有一个路径
mybatis:# 搜索指定包别名typeAliasesPackage: com.liu.activiti.pojo.*mapper-locations: classpath:mapper
springboot配置 扫描器
@MapperScan("com.liu.activiti.mapper")