Friday, June 22, 2012

How to load multiple Spring application context files in a standalone Java application

public class SpringMultipleApplicationContextExample
{

  //
  // define multiple spring application context files
  //
  private static final String[] SPRING_CONFIG_FILES = new String[]{"dao1Context.xml", "dao3Context.xml", "dao3Context.xml"};
 
  public static void main (String[] args)
  {
    new SpringMultipleApplicationContextExample();
  }

  public SpringMultipleApplicationContextExample()
  {
    //
    // load the spring application context files (multiple context files)
    //
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(SPRING_CONFIG_FILES);
  }

}

No comments:

Post a Comment