报错信息如下:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.user.dao.UserDao.XXX(方法名)
下面是我application.yml的配置:
server:
port: 8080
spring:
mybatis:
mapper-locations: classpath:mapper/*.xml
datasource:
url: jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=true
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
启动类配置:
@SpringBootApplication
@MapperScan("com.example.user.dao")
public class Demo4Application {
public static void main(String[] args) {
SpringApplication.run(Demo4Application.class, args);
}
}
项目结构:
UserDao.xml文件在resources的mapper下,UserDao接口在com.example.user.dao下
有没有大神帮忙看看哪里出的问题。直接在UserDao使用注解是可以访问到的,如下
@Select("SELECT * FROM user_t where id= #{id}")
@Results({
@Result(column = "id",property = "id"),
@Result(column = "user_name",property = "userName"),
@Result(column = "password",property = "password"),
@Result(column = "age",property = "age")
})
User selectByPrimaryKey(Integer id);
但就是访问不到xml文件中的方法,我使用的Idea2018,有没有大神指导指导,谢谢啦