zoukankan      html  css  js  c++  java
  • Spring加载上下文几种方式(Spring配置XML)

    1:spring-mvc.xml中用import引入其他的配置文件
    <import resource="user_spring.xml" />
    2:在web.xml配置,应用服务去加载
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext*.xml,/WEB-INF/user_spring*.xml</param-value>
    </context-param>

    3:引用资源用XmlBeanFactory(不能实现多个文件相互引用)
      Resource resource = new ClassPathResource("appcontext.xml");
      BeanFactory factory = new XmlBeanFactory(resource);

    4:引用应用上下文用ClassPathXmlApplicationContext
      ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
      ApplicationContext factory=new ClassPathXmlApplicationContext("conf/userConfig.xml");
      ApplicationContext factory=new ClassPathXmlApplicationContext("file:G:/Test/src/appcontext.xml");

    5:用文件系统的路径引用应用上下文用FileSystemXmlApplicationContext
      ApplicationContext factory=new FileSystemXmlApplicationContext("src/applicationContext.xml");
      ApplicationContext factory=new FileSystemXmlApplicationContext("classpath:appcontext.xml");
      ApplicationContext factory=new FileSystemXmlApplicationContext("file:G:/Test/src/appcontext.xml");
      ApplicationContext factory=new FileSystemXmlApplicationContext("G:/Test/src/appcontext.xml");

    6:Web工程定制的加载方法 XmlWebApplicationContext
      ServletContext servletContext = request.getSession().getServletContext();
      ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext );

  • 相关阅读:
    在IDEA通过Maven构建Scala项目
    6.Pair RDD操作
    5.RDD的Action操作和持久化persist()
    29.Spark SQL发展史
    AirFlow初始化的时候遇到 Global variable explicit_defaults_for_timestamp needs to be on (1) for mysql
    4.RDD操作之Transform
    3.RDD详解和创建RDD方式
    28.Spark中action的介绍
    2.Spark 2.x 集群部署和测试
    Repeater分页
  • 原文地址:https://www.cnblogs.com/proli/p/6760326.html
Copyright © 2011-2022 走看看