- 没有在Spring_config.xml配置包扫描
<context:component-scan base-package="top.aweiwei.www.service"></context:component-scan>
- 注入的类没有加注解
- .在web.xml里没有加载spring容器(监听器一定要有,我就是忘记加监听器,所以注入失败)
<!--Spring 配置 并添加监听-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring_config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>