@ContextConfiguration
Basic example on DZone
Watch out that the dependency tree is clean. If ComponentScan can pick up two matching beans you'll get NoUniqueBeanDefinitionException.
Unsatisfied dependency expressed through field 'xxx'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'xxx' available: expected single matching bean but found 2
It can happen in case of running integration tests from same package as unit tests. If for Unit test we use specific @ContextConfiguration. Then beans will be taken from specific class. Then if in integration tests we want to use default context it will pick beans from main as well from test directory.
Solution found on SO
I annotated service in application with @Qualifier("qualifier_name")
And then in the application controller I set that it is using only dependency with specific "qualifier_name".