web.xml中配置Spring容器随项目启动

<!-- 可以让spring容器随项目的启动而创建,随项目的关闭而销毁 -->
  <listener>
   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

  </listener>


  <!-- 指定加载spring配置文件的位置 -->
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>classpath:applicationContext.xml</param-value>
  </context-param>

猜你喜欢

转载自blog.csdn.net/saafdgvsdg/article/details/80370482