- 创建数据库,插入数据
INSERT INTO USER (id,NAME,age,email) VALUES
(1,'Jone',18,'11.com'),
(2,'liue',18,'dd.com'),
(3,'Jone',18,'11.com'),
(4,'Jone',18,'11.com'),
(5,'kkf',18,'11.com');
- pojo下的User类
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
private long id;
private String name;
private Integer age;
private String email;
}
- userMapper
啥也不用写
@Repository//代表持久层
public interface UserMapper extends BaseMapper<User> {
}
- 启动类
//扫描mapper文件夹
@MapperScan("com.kuang.mapper")
@SpringBootApplication
注意:需要在主启动类中去扫描包下的所有接口