• 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")
  • 相关阅读:
    WC项目
    团队项目(MVP新能源无线充电管理网站)(总结)
    学期目标
    个人目标、思维导图、不同点
    结对项目——黄金分割点游戏(陈香宇&蔡春燕)
    团队项目(MVP新能源无线充电管理网站)(个人任务2)
    四则运算
    读后疑问
    crontab 定时任务
    mysql主从配置
  • 原文地址:https://www.cnblogs.com/xym4869/p/8478074.html
Copyright © 2020-2023  润新知