Spring框架中拆分spring配置文件

在java项目中:

  applicationContext1.xml  -> ApplicationContext conext=new ClassPathXmlApplicationContext("applicationContext.xml1")

  applicationContext2.xml-> ApplicationContext conext=new ClassPathXmlApplicationContext("applicationContext.xml2")

  applicationContext3.xml-> ApplicationContext conext=new ClassPathXmlApplicationContext("applicationContext.xml3")

在web项目中:

    根据什么来拆分?

    1、三层结构

        UI(html/css/jsp\servlet) applicationContextControl.xml

        Service  applicationContextService.xml

        Dao   applicationContextDao.xml

        公共 数据库 

    2、功能结构

        例如:学生配置相关 applicationContextStudent.xml

           班级相关配置 applicationContextClass.xml

    如何将多个合并

        1、<param-value>classpath:applicationContextStudent.xml

          applicationContextClass.xml

        </param-value>

        

        2、<param-value>classpath:applicationContextStudent.xml

          applicationContext-*.xml //前面相同

        </param-value>

        3、在主配置文件中引入其他文件<import resource=" ">

猜你喜欢

转载自www.cnblogs.com/lmff/p/12767769.html