zoukankan      html  css  js  c++  java
  • Injection of autowired dependencies failed

    error:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mainController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.euphe.repository.UserRepository com.euphe.controller.MainController.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Using named parameters for method public abstract void com.euphe.repository.UserRepository.updateUser(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Integer) but parameter 'qPassword' not found in annotated query ' update UserEntity us set us.nickname = :qNickname, us.firstName=:qFirstName, us.lastName =:qLastName, us.password =: qPassword where us.id =:qId'!

     
    问题:这个函数没办法识别qPassword
    解决:原函数是这样的:
    @Query(" update UserEntity us set us.nickname = :qNickname, us.firstName=:qFirstName, " +
            "us.lastName =:qLastName, us.password =: qPassword where us.id =:qId")
    看出问题来了吗?qPassword和别的的不同就是和:之间多了一个空格,所以没有被识别出来,自然不能Autowired了
     
    修改之后:
    @Query(" update UserEntity us set us.nickname = :qNickname, us.firstName=:qFirstName, " +
            "us.lastName =:qLastName, us.password =:qPassword where us.id =:qId")
  • 相关阅读:
    页面滚动
    tcbRouter
    http缓存策略
    Ajax跨域
    tcp 3次握手和4次挥手
    http头字段
    http工作原理
    一个下载Windows镜像的地址
    安装MySQL-8.0.13
    配置Java,jdk环境变量
  • 原文地址:https://www.cnblogs.com/xym4869/p/8478074.html
Copyright © 2011-2022 走看看