Error creating bean with name ‘demoService’: Injection of resource
dependencies failed; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No
matching bean of type [swust.seclab.domain.Role] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for
this dependency. Dependency annotations:
{@javax.annotation.Resource(shareable=true, mappedName=, description=,
name=, type=class java.lang.Object, authenticationType=CONTAINER)}

说明demoService没有加入到Spring的容器中,目前想到的有2种可能

  1. demoService类中没有添加注释,导致Service不能加入到容器中。
  2. 如果是component-scan(包扫描)的情况,需要考虑demoService是否加入到了扫描的路径下。
Logo

云原生社区为您提供最前沿的新闻资讯和知识内容

更多推荐