让spring随着web容器的启动而启动

web.xml

ctrl + shift + t搜索contextloadlistener,复制完整类名

配置listener,配置全局参数

<!-- 监听器:spring随web项目的启动而启动 -->
  <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!-- 配置spring配置文件的位置 -->
  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:application.xml</param-value>
  </context-param>

猜你喜欢

转载自blog.csdn.net/qq_36084681/article/details/80481468