添加mybatis-plus的依赖即可
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
我是使用的easy-code自动生成controller、dao、entity、service。
刚开始报找不到mapper
Consider defining a bean of type ”xxxDao“
在启动类上添加了一个@MapperScan的注解
@SpringBootApplication
@MapperScan(value = "njts.zjq.couch.dao")
public class CouchApiApplication {
public static void main(String[] args) {
SpringApplication.run(CouchApiApplication.class, args);
}
}
启动成功!
这里有几个注意的点就是配置文件这一块,这都是一些基本的配置保证它可以跑得起来。
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/sofa?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
server:
port: 8080
servlet:
context-path: /couch
mybatis:
type-aliases-package: njts.zjq.couch.entity
mapper-locations: classpath:mapper/*.xml