- 按照mybatis-plus的官方文档,依赖什么的都导入正确,但查询出来的结果都是null
- 建了一个简单的User实体类可以查出来,用复杂点的实体类就为null
- 测试类
@RunWith(SpringRunner.class)
@SpringBootTest
class MybatisPlusApplicationTests {
@Autowired
private TeacherMapper teacherMapper;
@Test
void contextLoads() {
System.out.println(("----- selectAll method test ------"));
Teacher teacher = teacherMapper.selectById(1);
System.out.println(teacher);
}
}
- 实体类
public class Teacher implements Serializable{ private int teacher_id; private String teacher_username; private String teacher_password; private String teacher_name; private String teacher_sex; private int teacher_age; private String teacher_phone; private String teacher_address; private String courses_id;
- mapper接口
public interface TeacherMapper extends BaseMapper<Teacher> { }