You can use @Qualifier annotation
From here
Fine-tune auto-tuning based on annotations with qualifiers
Since auto-negotiation by type can lead to multiple candidates, it is often necessary to have more control over the selection process. One way to achieve this is with the Spring @Qualifier annotation. This allows you to associate qualifier values ββwith specific arguments, narrowing the set of type matches so that a specific bean is selected for each argument. In the simplest case, this may be a simple descriptive value:
class Main { private Country country; @Autowired @Qualifier("country") public void setCountry(Country country) { this.country = country; } }
This will use the UK by adding an identifier in the USA bean and use this if you want the USA.
Paul Whelan Dec 15 '10 at 8:13 2010-12-15 08:13
source share