导入依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>官网查找</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>官网查找</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>官网查找/version>
</dependency>
yml配置
mysql,mybatis-plus的基础配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/${dbName}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456
mybatis-plus:
mapper-locations: classpath:"路径"/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
default-statement-timeout: 3 # 查询超时间,单位秒,不设置则无线等待
default-fetch-size: 100
map-underscore-to-camel-case: true
local-cache-scope: session #默认为session 开启 @Transactional 事务注解,即可启用
cache-enable: true
global-config:
refresh-mapper: true