spring配置文件随服务器启动时自动加载

<!--配置监听器 --> <!--以便在服务器启动的时候,加载spring配置文件-->
  <listener>
    <listener-class>
     org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <!--配置spring配置文件-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/spring-context.xml</param-value>
  </context-param>

注:这里注意标签中中的内容为固定值,中内容为固定格式:classpath:spring配置文件(如有路径请加上)

通过以上配置就可以让spring配置文件随服务器启动而加载了。

猜你喜欢

转载自blog.csdn.net/libaoleilibaolei/article/details/88576224