Mybatis在springboot中的mapper.xml文件开头如何书写
Mybatis在springboot中的mapper.xml文件开头如何书写
stuSelectMapper.java 文件
@Repository
@Mapper
public interface stuSelectMapper {/*** 返回女孩* @return*/List findGirls();
}
stuSelectMapper.xml 文件
其中:
namespace:对应Mapper文件所在"地址",即Mapper文件所在包名.Mapper名.务必要写正确!!!insert/delete/updata/select id: 对应要实现的方法的名称.resultType: 返回值的类型. 实体类名称.返回的是List,只需要写stu即可,stu是一个类。完整的写法应该是 resultType="com.ylyang.learning.app.entity.stu"。但是在yml文件中配置时我们配置了type- aliases-package: com.ylyang.learning.app.entity,指明了实体类所在位置。因此,此时可简写resultType="stu"insert、update、delete 使用的是 parameterType.select 使用的是 resultType.-->
注:namespace中必须为stuSelectMapper类的完整命名,这样stuSelectMapper类就和stuSelectMapper.xml文件绑定到一起了。
这样就可以看作是:stuSelectMapper中声明了要实现什么功能;stuSelectMapper.xml中告知具体怎么实现这个功能。
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
