@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;
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方法,无法进行属性的注入