maven依赖
<!--mybatis-plus依赖-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.3.1</version>
</dependency>
<!--jdbc-->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
数据源配置
spring:
#JDBC
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver #驱动
username: xxxxxxx #数据库账号
password: xxxxxxx #数据库密码
name: test
url: jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&useTimezone=true&allowMultiQueries=true
#JDB连接池配置
hikari:
pool-name: hikari-spring-demo-1 #连接池名称
connection-timeout: 60000 #请求连接的超时时间
maximum-pool-size: 20 #最大连接数量
max-lifetime: 1800000 #连接的最长生命周期
keepalive-time: 1750000 #尝试保持连接的频率
connection-test-query: select 1 #连接验证sql
mybatis-plus配置
#mybatis-plus配置
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl #日志接口
default-executor-type: batchn #指定mybatis的执行器
map-underscore-to-camel-case: true #是否开启自动驼峰命名规则(camel case)映射
global-config:
banner: false #是否控制台 print mybatis-plus 的 LOGO
mybatis-plus的默认配置已经能够满足开箱即用,如需要个性配置,参考mybatis-plus配置,配置完成后,使用代码生成器生成代码,然后测试即可。