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")
原文地址:https://www.cnblogs.com/xym4869/p/8478074.html