错误描述如下所示:
我们将错误拉到最下面如下所示为导致异常的原因:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.reviewmybatisplus.Service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801) ~[spring-beans-5.3.30.jar:5.3.30]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357) ~[spring-beans-5.3.30.jar:5.3.30]at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.30.jar:5.3.30]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:710) ~[spring-beans-5.3.30.jar:5.3.30]... 76 common frames omitted
出现上述的错误在于我们NoSuchBeanDefinitionException: No qualifying bean of type'com.example.reviewmybatisplus.Service.UserService'
,也就是说我们没有匹配的Bean,UserService为我们的持久化层接口,而IOC容器所管理的bean对象只能是类而不能是接口,因此我们只需要给该接口对应的类上添加@Repository将其交给IOC容器管理即可解决