天天看點

ClassPathXmlApplicationContext加載多個配置檔案ClassPathXmlApplicationContext加載多個配置檔案

ClassPathXmlApplicationContext加載多個配置檔案

一共有兩種方法:

第一種:數組方式

String[] configLocations = new String[]{“spring/applicationContext-dao.xml”,“spring/applicationContext-service.xml”,“spring/applicationContext-trans.xml”};

ApplicationContext ac = new ClassPathXmlApplicationContext(configLocations);

第二種:* 比對

ApplicationContext ac = new ClassPathXmlApplicationContext(“classpath:applicationContext-*.xml”);

繼續閱讀