Search code examples
xmlspringmavenprogram-entry-pointcontext.xml

I want to run main() loading spring context xml with another project's xml & source


I have to two java projects. One is a main and the other is imported project to the main. Using Maven, I load both project's spring context xml. But If I want to execute below in the main project But, this source can't load imported project's xml. please help me. I want to load the other project's spring context xml and source.

public static void main(String[] args) {
    @SuppressWarnings("unused")
    ApplicationContext context= new ClassPathXmlApplicationContext("/spring/context-*.xml");
}

Solution

  • I don't think you can use * in that particular path. You need to explicitly specify the context files, e.g.

    ApplicationContext context= new ClassPathXmlApplicationContext(
        "/spring/context-a.xml",
        "/spring/context-b.xml");