使用<context:component-scan base-package="" ></context:component-scan>报500错误

今天练习SSH小程序,在springmvc.xml中使用<context:component-scan base-package="" ></context:component-scan> 组件扫描controller的时候,一直报500错误,在网上查了很久没有解决。错误如下

 于是便将其注释掉,使用<bean class=""></bean>使用bean来一个个添加。。500错误没有了,但是来了个空指针异常。我打印输出了service对象值

难道是itemsService没有注入成功?于是我spring.xml中加入代码<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>问题才解决。。但是我在看视频教程的时候,老师使用<context:component-scan 后并没有使用<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>。。所以怎样解决我这种使用<context:component-scan base-package="" ></context:component-scan>报500错误啊  ~~~~(>_<)~~~~????

原文地址:https://www.cnblogs.com/zl120439073/p/6901929.html