關(guān)于用list裝配的問(wèn)題
@Autowired
private List<Store> list ;
@Bean
public StringStore stringStore(){
return new StringStore();
}
@Bean
public IntegerStore integerStore(){
return new IntegerStore();
}
@Bean(name = "stringStoreTest")
public Store stringStoreTest(){
????????if(list != null && list.size() != 0){
???????? for (Store store : list) {
???????? System.out.println(store.getClass().getName());
???????? }
???????? }else{
???????? System.out.println("No!!!!!!");
???????? }
????????
???????? return new StringStore();
}
結(jié)果返回為空,我也覺(jué)得應(yīng)該是有問(wèn)題的,因?yàn)樽詣?dòng)裝載的時(shí)候,會(huì)分不清楚是裝載哪個(gè)bean所以,問(wèn)問(wèn)各位大神
謝謝大家?。。?/p>
2019-05-11
你類(lèi)忘寫(xiě)@Component了吧
2018-10-24
你的StringStore類(lèi)型和IntegereStore類(lèi)型在實(shí)現(xiàn)Store<T>泛型時(shí),類(lèi)型是否一致?把其他兩個(gè)類(lèi)給出來(lái)。