Can I compose a Spring Configuration File from smaller ones?

前端 未结 7 1902
后悔当初
后悔当初 2021-02-13 02:38

I have a handful of projects that all use one project for the data model. Each of these projects has its own applicationContext.xml file with a bunch of repetitive data stuff w

7条回答
  •  醉梦人生
    2021-02-13 03:21

    Given what Nicholas pointed me to I found this in the docs. It allows me to pick at runtime the bean contexts I'm interested in.

    GenericApplicationContext ctx = new GenericApplicationContext();
    XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
    xmlReader.loadBeanDefinitions(new ClassPathResource("modelContext.xml"));
    xmlReader.loadBeanDefinitions(new ClassPathResource("uiContext.xml"));
    ctx.refresh();
    

提交回复
热议问题