Posts

Spring Multiple Configuration File

 Spring Multiple beans Configuration File In a large project, we may have more than one Spring's bean configuration files. Put every single bean definition in a single file is hard to maintain. And they may be stored in different folder structures. For example, we may have a Spring-Common.xml in common folder, a Spring-Connection.xml in connection folder, and a Spring-ModuleA.xml in ModuleA folder. Load one by one One way to load the configuration files is to load them one by one. For example, we put all above three xml files in classpath project-classpath/Spring-Common.xml project-classpath/Spring-Connection.xml project-classpath/Spring-ModuleA.xml Then we can use the following code to load multiple Spring bean configuration files. ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "Spring-Common.xml" , "Spring-Connection.xml" , "Spring-ModuleA.xml" }); The code above pass in all file na
Recent posts