上一篇博客中,我们通过Mybatis
的Generator
命令,生成了Pojos
,本文将继续介绍,如何根据Mybatis
生成的内容,添加Controller
和Service
,实现RESTful API
上文:Spring Boot整合MyBatis,自动生成DAO
3. 修改Mapper
我们尝试修改一下Mapper
,在BooksMapper.java
中,增加以下内容:
@Select({
"select",
"id, name, author, publish",
"from books",
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
@Result(column="name", property="name", jdbcType=JdbcType.CHAR),
@Result(column="author"