Skip to content
Playground for Spring application context created from modules using Java and XML config
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Spring fun

Example for blog post:

The project contains two client modules (client-with-java-config, client-with-xml-config) which both depend on the legacy-module which uses Spring XML config.

The legacy-module defines a GreetingService with an implementation (DutchGreetingService) and also a client of this GreetingService which is GreetingServiceClient

Now in the two client modules we depend on the legacy-module and use the GreetingServiceClient but we would like to override the GreetingService with its own implementation.

Client with XML Config

In the client-with-xml-config module we construct the application context like this:

ApplicationContext applicationContext = new ClassPathXmlApplicationContext(

The ordering of the resources matter. In the above scenario the DutchGreetingService from legacy-module will be overridden by the HungarianGreetingSerivce since both have the same id greetingService.

Client with Java Config

In the client-with-java-config module the default is the HungarianGreetingService which is always overridden by the DutchGreetingService from legacy-module. We cannot control the ordering of the resources when the combined application context is created.

@ImportResource(value = "classpath*:/META-INF/spring/module-context.xml")
You can’t perform that action at this time.