mybatis-plus查询为null

  1. 按照mybatis-plus的官方文档,依赖什么的都导入正确,但查询出来的结果都是null
  2. 建了一个简单的User实体类可以查出来,用复杂点的实体类就为null
  3. 测试类
@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);
    }

}
  1. 实体类 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;
  2. mapper接口 public interface TeacherMapper extends BaseMapper<Teacher> { } 图片说明

实体类Teacher没有表注解啊。 我的是这样的

import com.baomidou.mybatisplus.extension.activerecord.Model;
...

@Data
@TableName("hotel")
@ApiModel(value="Hotel对象", description="酒店表")
public class Hotel extends Model<Hotel> {
  @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
.....
}

实体类没有自定义set和get方法,无法进行属性的注入