问答详情
源自:4-2 Spring Bean装配之Autowired注解说明-1

注解报错找不到

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

https://img4.mukewang.com/5bbf513b0001156d02900278.jpg

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

https://img4.mukewang.com/5bbf513b0001006b09000329.jpg


报错:

 Error creating bean with name 'injectionServiceImpl': Unsatisfied dependency expressed through field 'injectionDAO'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.serena.ioc.injection.dao.InjectionDAO' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


想请大家帮忙看看,谢谢啦!!


提问者:Serena_Cecilia 2018-10-11 21:34

个回答

  • qq_璀璨明天_0
    2018-10-12 10:54:15
    已采纳

    类地址需要改成 你自己的

  • Serena_Cecilia
    2018-10-12 11:04:01

    还想请问一下,就是视频后面对setter和构造函数加sutowired的注解,会不会不是那么必要?


  • qq_璀璨明天_0
    2018-10-12 11:00:08

    com.serena.ioc.injection.dao.InjectionDAO   你引包引错了  应该改是com.serena.injection.dao.InjectionDAO

  • qq_璀璨明天_0
    2018-10-12 10:53:29

    <bean id="injectionService" class="com.imooc.ioc.injection.service.InjectionServiceImpl">

            <constructor-arg name="injectionDAO" ref="injectionDAO"></constructor-arg>

            </bean>

            

            <bean id="injectionDAO" class="com.imooc.ioc.injection.dao.InjectionDAOImpl"></bean>

    看看你的XML  文件 对吗?