I have been working on OSGI and Spring based applications for last few months and only now I have noticed that I don't specify which XML files to load for spring configuration. So how does Karaf know which files to load?
My project is Maven based and it uses maven-bundle-plugin to build OSGI bundle. As project is maven based it follows simple maven directory structure like below.
src/
main/java/
main/resources/ ---/here I'm keeping my XML configuratoin files.
pom.xml
Karaf uses spring dynamic modules (spring dm) internally to work with spring based bundles. It looks at following locations in your bundle to check for configuration files.
META-INF/MANIFEST.MF (if Spring-Context attribute is present)
META-INF/spring (if it contains XML files)
Reference http://uniqueexperiments.blogspot.com/2015/09/spring-osgi-bundle-how-does-karaf-know.html
So short answer is it has predefined locations and if you don't put files in there it won't load them.