spring boot 2.x和hibernate整合 异常org.springframework.beans.factory.UnsatisfiedDependencyException

我在整合spring boot 2.x和hibernate时,启动报错,错误如下:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘menuServiceImpl’: Unsatisfied dependency expressed through field ‘menuDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘menuDao’: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract int com.sxzq.glq.user.modules.user.dao.MenuDao.updateMenuByCode(java.lang.String,java.lang.String)!
错误原因:
  我的数据库表名和对应的实体类不一致,而我是第一次使用hibernate,对其不是很了解,在dao层,sql语句中将操作的对象写成了数据库表名,导致这个错误
  错误代码:
  @Query(“update menu set name = :name where code = :code”)
  public int updateMenuByCode(@Param(“name”) String name,@Param(“code”) String code);
  我写的操作对象为menu,是我数据库的表名,我对应的实体类是MenuEntity,所以报错了,修改后正确的代码为:
  @Query(“update MenuEntity set name = :name where code = :code”)
  public int updateMenuByCode(@Param(“name”) String name,@Param(“code”) String code);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值