Spring框架中拆分spring配置文件

2020-04-24 15:37:44 蜻蜓队长

在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=" ">

以上内容来自于网络,如有侵权联系即删除
相关文章

上一篇: [原][osgearth]earth文件加载道路一初步看见模型道路

下一篇: 【Idea maven】springMvc访问不到静态资源的问题 (访问不到图片,css等

客服紫薇:15852074331
在线咨询
客户经理