springboot项目 先导入相关依赖
mybatis-plus相关依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
加快实体类开发使用lombok
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
2 端口号和数据库配置
1 server: 2 port: 8080 3 4 spring: 5 datasource: 6 driver-class-name: com.mysql.cj.jdbc.Driver 7 username: root 8 password: "131412" 9 url: jdbc:mysql://localhost:3306/user?serverTimezone=GMT%2B8&useSSL=false&useUnicode=true&characterEncoding=UTF-8
3创建实体类
4写一个UserMapper接口
1 package com.example.demo6.mapper; 2 3 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 import com.example.demo6.pojo.user; 5 import org.springframework.stereotype.Repository; 6 //代表持久层 继承BaseMapper后 就有了基本的曾删改查等功能 7 @Repository 8 public interface UserMapper extends BaseMapper<user> { 9 10 11 }
5主启动类扫描mapper接口
6测试类测试 查询全部数据
7配置日志
mybatis-plus:标签:mapper,springboot,plus,org,mybatis,import,com From: https://www.cnblogs.com/qiang1/p/17280865.html
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl