一、@TableName
经过一系列的测试,在使用MyBatis-Plus实现基本的CRUD时,我们并没有指定要操作的表,只是在 Mapper接口继承BaseMapper时,设置了泛型User,而操作的表为user表
由此得出结论, MyBatis-Plus在确定操作的表时,由BaseMapper的泛型决定,即实体类型决 定,且默认操作的表名和实体类型的类名一致
若实体类类型的类名和要操作的表的表名不一致,会出现什么问题?
将表user更名为t_user ,测试查询功能
测试类
package com.qcby.mybatisPlus;
import com.qcby.mybatisPlus.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class ZhujieTest {
@Autowired
private UserMapper userMapper;
/*
* 根据id查询
* */
@Test
public void testGetById(){