springboot 无法注入。Error creating bean with name ‘xxxxx‘: Injection of resource dependencies failed; ne

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxxxx': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxx.xxx.xxx.XXX' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

在@SpringBootApplication 启动类上加上 scanBasePackages 即可

类似这个

@SpringBootApplication(scanBasePackages = {"com.xxx"})

猜你喜欢

转载自blog.csdn.net/qq_36838406/article/details/131068625