UnsatisfiedDependencyException: Error creating bean with name

后端 未结 19 962
遇见更好的自我
遇见更好的自我 2020-11-30 01:47

For several days I\'m trying to create Spring CRUD application. I\'m confused. I can\'t solve this errors.

org.springframework.beans.factory.Unsatisfi

19条回答
  •  自闭症患者
    2020-11-30 02:22

    Considering that your package scanning is correctly set either through XML configuration or annotation based configuration.

    You will need a @Repository on your ClientRepository implementation as well to allow Spring to use it in an @Autowired. Since it's not here we can only suppose that's what's missing.

    As a side note, it would be cleaner to put your @Autowired/@Qualifier directly on your member if the setter method is only used for the @Autowired.

    @Autowired
    @Qualifier("clientRepository")
    private ClientRepository clientRepository;
    

    Lastly, you don't need the @Qualifier is there is only one class implementing the bean definition so unless you have several implementation of ClientService and ClientRepository you can remove the @Qualifier

提交回复
热议问题