How To Load Multiple Spring Bean Configuration Files

In general in spring projects we need to maintain different modules and different bean configuration file for specific module for maintainability and easy to understand.Consider there are 5 modules in our project like module1 and module2….module5 and one common module , so we have Six config files.

so we may write code like this to load all the configuration files and we need to put all the files in classpath.


If we go in above way lack of organizing and error prone, there is another way we can configure all the xml files which is better way compare to above approach which is easy and standard way.

By using <import> tag we can achieve this. Have look in to the below code how we configured i.e place all the module’s in one xml(all_modules.xml) and load that xml file.


load this way..



Happy learning Spring Tutorials… 🙂


Posted in Spring and tagged , .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.