You need to override the spring bean. Like in this answer: Spring's overriding bean
But this is only possible with XML configuration and not with annotations.
EDIT: I meant the accepted answer. But I tested it with my own code.
I got 2 id's. In test1.xml
<bean id="test" class="Test1" />
and in test2.xml
<bean id="test" class="Test2" />
During startup is use both "test1.xml", "test2.xml" (in that order) in the ApplicationContext en when I get the Spring bean test it's of class Test2.