问答详情
源自:4-1 基于bootstrap开发页面结构

运行程序报错,,错误的创建bean

我service的测试类ok的,也能访问index.jsp,就是访问list.jsp报错,,哪位大神帮忙看一下,,谢谢!


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'seckillServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.Seckill.dao.SeckillDao org.Seckill.service.impl.SeckillServiceImpl.seckillDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.Seckill.dao.SeckillDao] 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)}

  


Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.Seckill.dao.SeckillDao] 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)}

web.xml

https://img2.mukewang.com/5b4300f700010cf214070717.jpg

spring-web.xml

https://img.mukewang.com/5b4301ca0001784815610781.jpg

提问者:鲨鱼尖椒 2018-07-06 18:17

个回答

  • 慕粉3982481
    2018-07-12 17:33:17

    你的SeckillServiceImpl这个类是不是没有加注解,比如:@Service。不加注解的话,BeanFactory就不会知道他是一个Bean,这样,在SeckillController 中使用@Autowired注解注入的时候,Spring容器就会找不到对应的Bean