You can define a configuration file in module A
package you.organisation.moduleA.config;
@Configuration
@ImportResource("classpath:path/to/applicationContextA.xml")
public class ModuleAConfig implements Serializable {
}
and in the module B context file, you can access module A beans
<context:component-scan base-package="you.organisation.*.config" />
If you want to use Module B config files, tou do the same
package you.organisation.moduleB.config;
@Configuration
@ImportResource("classpath:path/to/applicationContextB.xml")
public class ModuleBConfig implements Serializable {
}
and in the module that will use it
<context:component-scan base-package="you.organisation.*.config" />
About best practices you must be careful when using wildcards, please have a look to the section 4.7.2.2