假设我有这样的接口:
interface Country {}
class USA implements Country {}
class UK implements Country ()
还有 xml 的这个配置片段:
<bean class="USA"/>
<bean id="country" class="UK"/>
<bean id="main" class="Main"/>
我怎样才能控制哪个依赖是下面自动连接的? 我想英国的一个。
class Main {
private Country country;
@Autowired
public void setCountry(Country country) {
this.country = country;
}
}
我正在使用 Spring3.0.3。