MyBatis找不到mapper.xml

时间:2018-01-10 12:34:46

标签: spring-boot mybatis

我使用 AnnotationConfigApplicationContext 启动一个控制台应用程序,主类使用 @ComponentScan(basePackages = {" com.hello"})进行注释然而。它会导致错误

  

无效的绑定语句(未找到):   com.hello.user.dao.AccountDao.remove

但是,如果我使用带有application.yml的 FileSystemXmlApplicationContext 启动应用程序就好了

mybatis:
  mapperLocations: classpath:com/hello/user/dao/mapper/*.xml, classpath:com/hello/task/dao/mapper/*.xml

使用 AnnotationConfigApplicationContext 和mapper xml

应该怎么做

1 个答案:

答案 0 :(得分:0)

对于AnnotationConfigApplicationContext,在资源文件夹中添加配置文件。