在使用IDEA启动Tomcat时遇到控制台报错,具体为'Context initialization failed',原因是在'productServiceImpl'的bean创建过程中,autowired依赖注入失败。错误信息显示找不到qualifying bean of type [com.how2java.tmall.service.ProductService]。解决办法是检查发现serviceImpl中的某个未使用的@Autowired注解,删除这个未使用的ProductService字段即可正常启动Tomcat。
Error creating bean with name 'orderItemServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.how2java.tmall.service.ProductService com.how2java.tmall.service.impl.OrderItemServiceImpl.productService;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could
not autowire field: com.how2java.tmall.service.ProductService com.how2java.tmall.service.impl.ProductServiceImpl.productService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.how2java.tmall.service.ProductService]
found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
: Error creating bean with name 'productServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.how2java.tmall.service.ProductService com.how2java.tmall.service.impl.ProductServiceImpl.productService;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.how2java.tmall.service.ProductService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 找了好久的错误:结果是serviceImpl中某一个class的