bean reference injection

This commit is contained in:
mherbaghinyan 2018-05-22 16:33:25 +04:00
parent 4cdf7fe9ef
commit a6655de20c
4 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,7 @@
package com.baeldung.collection;
/**
* Created by Gebruiker on 5/22/2018.
*/
public class BaeldungBean {
}

View File

@ -26,4 +26,19 @@ public class CollectionConfig {
nameMap.put(3, "Harry");
return nameMap;
}
@Bean
public BaeldungBean getElement() {
return new BaeldungBean();
}
@Bean
public BaeldungBean getAnotherElement() {
return new BaeldungBean();
}
@Bean
public BaeldungBean getOneMoreElement() {
return new BaeldungBean();
}
}

View File

@ -15,5 +15,6 @@ public class CollectionInjectionDemo {
collectionsBean.printNameList();
collectionsBean.printNameSet();
collectionsBean.printNameMap();
collectionsBean.printBeanList();
}
}

View File

@ -18,6 +18,9 @@ public class CollectionsBean {
private Map<Integer, String> nameMap;
@Autowired
private List<BaeldungBean> beanList;
public CollectionsBean() {
}
@ -41,4 +44,8 @@ public class CollectionsBean {
public void printNameMap() {
System.out.println(nameMap);
}
public void printBeanList() {
System.out.println(beanList);
}
}