说明
与mybatis原本的SQL查询相似,通过mapper类,mapper.xml添加
在自己写的mapper接口中添加方法
@Repository
public interface UserMapper extends BaseMapper<User> {
public User selectByUserName(String username);
}
编写mapper.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gui.mapper.UserMapper">
<select id="selectByUserName" resultType="com.gui.pojo.User">
select * from user where username = #{username}
</select>
</mapper>

在配置文件application中的添加mapper.xml的路径
mybatis-plus.mapper-locations=classpath:mapper/*.xml
测试使用
