创建模块时候要勾选MyBatis Framework 和MYSQL Driver 这俩个技术。
@Mapper @Repository public interface BookDao { @Select("select * from tbl_book where id = #{id}") public Book getById(Integer id); }
@Data public class Book { private Integer id; private String type; private String name; private String description; }
@SpringBootTest class Springboot05MybatisApplicationTests { @Autowired private BookDao bookDao; @Test void contextLoads() { System.out.println(bookDao.getById(1)); } }