如何在春季使用注释按名称自动布线?
我定义了同一类的几个豆子:
@Bean
public FieldDescriptor fullSpotField() {
FieldDescriptor ans = new FieldDescriptor("full_spot", String.class);
return ans;
}
@Bean
public FieldDescriptor annotationIdField() {
FieldDescriptor ans = new FieldDescriptor("annotationID", Integer.class);
return ans;
}
因此,当我自动连接它们时
@Autowired
public FieldDescriptor fullSpotField;
@Autowired
public FieldDescriptor annotationIdField;
我遇到异常
NoUniqueBeanDefinitionException: No qualifying bean of type [...FieldDescriptor] is defined: expected single matching bean but found ...
如何在XML配置中尽可能按名称自动连接?