Invalid bound statement (not found): com.atguigu.springcloud.dao.PaymentDao.getPaymentById错误

程序运行正常,但是进行增删改查就报这个错
意思大概是找不到dao层中的getPaymentById这个方法,我百度了一下大概由这么几种情况:
第一种:mapper.xml文件中的绑定地址错误,namespace后面的地址是否跟自己的dao层地址相同
mapper namespace=“com.atguigu.springcloud.dao.PaymentDao”

第二种:mapper.xml中id值跟dao层中的方法名是否相同,一定要相同
dao层代码

public interface PaymentDao {

    public List<Payment> ListPayment();

    public int create(Payment payment);

    public Payment getPaymentById(int id);

    public int delete(int id);

    public int update(Payment payment);

}

mapper.xml部分代码

	select id="ListPayment",
	insert id="create",
	select id="getPaymentById",
	delete id="delete",
	update id="update"

第三种:application.yml 或者是application.properies配置文件中没有mybatis的配置,或者是用的.yml文件格式有问题,冒号‘:’后面需要有一个空格

spring:
    application:
    nama: cloud-payment-service
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/数据库名?serverTimezone=UTC
    username: root
    password: 数据库密码

mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.atguigu.springcloud.entities

我的错误就是第三种,但不是我的问题,是因为版本更新了的原因,里面的 mapperLocation没有了,需要改成mapper-locations
错误的如下:
在这里插入图片描述
正确的如下:
在这里插入图片描述
如有问题欢迎指导谢谢

转载请注明出处,支持原创,谢谢!

  • 13
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值