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

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐