This commit is contained in:
mherbaghinyan 2018-05-22 17:07:08 +04:00
parent a6655de20c
commit fa60d4e69e
2 changed files with 8 additions and 0 deletions

View File

@ -1,7 +1,9 @@
package com.baeldung.collection; package com.baeldung.collection;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import java.util.*; import java.util.*;
@ -28,16 +30,20 @@ public class CollectionConfig {
} }
@Bean @Bean
@Qualifier("CollectionsBean")
@Order(2)
public BaeldungBean getElement() { public BaeldungBean getElement() {
return new BaeldungBean(); return new BaeldungBean();
} }
@Bean @Bean
@Order(3)
public BaeldungBean getAnotherElement() { public BaeldungBean getAnotherElement() {
return new BaeldungBean(); return new BaeldungBean();
} }
@Bean @Bean
@Order(1)
public BaeldungBean getOneMoreElement() { public BaeldungBean getOneMoreElement() {
return new BaeldungBean(); return new BaeldungBean();
} }

View File

@ -1,6 +1,7 @@
package com.baeldung.collection; package com.baeldung.collection;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -19,6 +20,7 @@ public class CollectionsBean {
private Map<Integer, String> nameMap; private Map<Integer, String> nameMap;
@Autowired @Autowired
@Qualifier("CollectionsBean")
private List<BaeldungBean> beanList; private List<BaeldungBean> beanList;
public CollectionsBean() { public CollectionsBean() {