org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

springboot+mybatis项目启动时,有异常信息如下:

      Property 'mapperLocations' was not specified.

接口访问时报错如下:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.test.mapper.TestMapper.getTest
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53)
    at org.apache.ibatis.binding.MapperProxy.lambda$cachedMapperMethod$0(MapperProxy.java:62)
    at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:62)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:57)
    at com.sun.proxy.$Proxy141.getTest(Unknown Source)
    at com.test.service.impl.TestServiceImpl.getTest(TestServiceImpl.java:28)
    at com.test.controller.TestController.getTest(TestController.java:34)

原因是:未找到mapper.xml文件

解决方案:

1、将mapper.xml文件放到resources目录下

2、pom.xml文件中加上<resources>,接口可成功访问

<resources>
   <resource>
      <directory>src/main/java</directory>
      <includes>
         <include>**/*.xml</include>
      </includes>
      <filtering>false</filtering>
   </resource>
   <resource>
      <directory>src/main/resources</directory>
      <includes>
         <include>**/*.*</include>
      </includes>
      <filtering>false</filtering>
   </resource>
</resources>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值