Spring Autowiring Service doesn't work in my Controller

前端 未结 7 2000
时光说笑
时光说笑 2021-02-04 13:43

i\'ve problems in order to autowire a service in my controller. I\'ve this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean wi         


        
7条回答
  •  暖寄归人
    2021-02-04 14:29

    You need to change the way you have autowired the service in the controller.

    Change the following code

    @Autowired
    private UserService userService;
    

    with following

    @Resource(name="userService")
    private UserService userService;
    

    Because in the UserServiceImpl you have defined the @Service annotation with alias "userService".

    I hope this would resolve your problem. :)

提交回复
热议问题