1.需要在web.xml中添加spring的配置:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/applicationContext.xml</param-value>
</context-param>
<!-- 配置spring启动listener入口 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener- class>
</listener>
2.创建spring的配置文件applicationContext.xml: