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配置文件随服务器启动而加载了。


版权声明:本文为libaoleilibaolei原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。