Моя версия springboot: 2.3.2 Моя версия mybatis: 3.5.5 Я поместил UserDao. xml в "/ resource / mapper"
это UserDao:
package com.lmx.myblog.dao;
import com.lmx.myblog.po.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface IUserDao {
User findUserByPassword(@Param("username") String username, @Param("password") String password);
}
это UserDao. 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.lmx.myblog.dao.IUserDao">
<select id="findUserByPassword" resultType="User" >
select * from t_user where username=#{username} and password=#{password};
</select>
</mapper>
это application.yml:
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
datasource:
username: root
password: 123456
url: jdbc:mysql://localhost:3306/blog?useUnicode=true&serverTimezone=UTC&characterEncoding=utf-8
driver-class-name: com.mysql.cj.jdbc.Driver
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.lmx.myblog.po