Invalid bound statement (not found)

Springboot整合mybaits出现Invalid bound statement


最近在学习springcloud记录一下自己挖的坑。由于springcloud基于springboot,然后就去整合springboot和mybatis,运行项目出现

Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

但是已经在application.properties配置了datasource了,然后就去target目录下查找配置文件,发现并配置文件并没有部署到target/classes文件下。后来经过排查是文件名写错了resources写成了resouces。然后执行maven clean install配置文件正常部署并运行项目,访问url出现以下提示。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.demo.mapper.ItemDoMapper.selectByPrimaryKey
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.4.jar:3.5.4]
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) ~[mybatis-3.5.4.jar:3.5.4]
	at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:107) ~[mybatis-3.5.4.jar:3.5.4]
	at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source) ~[na:1.8.0_241]
	at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:94) ~[mybatis-3.5.4.jar:3.5.4]
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) ~[mybatis-3.5.4.jar:3.5.4]
	at com.sun.proxy.$Proxy94.selectByPrimaryKey(Unknown Source) ~[na:na]
	at com.demo.service.ItemServiceImpl.selectByPrimaryKey(ItemServiceImpl.java:58) ~[classes/:na]
	at com.demo.controller.ItemController.publ(ItemController.java:36) ~[classes/:na]

不对啊配置文件是正常部署的啊,为什么会访问不了mapper.xml文件呢,百度了很久给出的解决方法以下

  1. 接口中方法名与xml文件中 id是否一致
  2. xml文件中的 namespace=“xxx.xxx.xxx.Mapper” 中的路径是否与接口文件路径一致
  3. parameterType类型 与 resultType类型是否准确;resultMap与resultType是不一样的
  4. 如果上述都没问题,检查编译后的目录中是否存在mapper文件,如果没有则在对应模块的pom中加如下依赖,告诉SpringBoot不要去忽略xml文件
<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>xxx/*.xml</include>
        </includes>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
    </resource>
</resources>

根据以上的方案检查完还是报错,然后就去检查一下application.properties文件,发现classpath多了一个(=)等号
在这里插入图片描述
一直混在绿色里面没注意到,删除 = 后项目正常运行。
自己给自己挖坑,特此记录一下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值