File tree Expand file tree Collapse file tree
spring-core/src/main/java/com/baeldung/collection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,5 +16,6 @@ public static void main(String[] args) {
1616 collectionsBean .printNameSet ();
1717 collectionsBean .printNameMap ();
1818 collectionsBean .printBeanList ();
19+ collectionsBean .printNameListWithDefaults ();
1920 }
2021}
Original file line number Diff line number Diff line change 11package com .baeldung .collection ;
22
3- import org .springframework .beans .factory .annotation .Autowired ;
4- import org .springframework .beans .factory .annotation .Qualifier ;
5-
63import java .util .ArrayList ;
74import java .util .List ;
85import java .util .Map ;
96import java .util .Set ;
107
8+ import org .springframework .beans .factory .annotation .Autowired ;
9+ import org .springframework .beans .factory .annotation .Qualifier ;
10+ import org .springframework .beans .factory .annotation .Value ;
11+
1112/**
1213 * Created by Gebruiker on 5/18/2018.
1314 */
@@ -24,6 +25,9 @@ public class CollectionsBean {
2425 @ Qualifier ("CollectionsBean" )
2526 private List <BaeldungBean > beanList = new ArrayList <>();
2627
28+ @ Value ("${names.list:}#{T(java.util.Collections).emptyList()}" )
29+ private List <String > nameListWithDefaultValue ;
30+
2731 public CollectionsBean () {
2832 }
2933
@@ -51,4 +55,8 @@ public void printNameMap() {
5155 public void printBeanList () {
5256 System .out .println (beanList );
5357 }
58+
59+ public void printNameListWithDefaults () {
60+ System .out .println (nameListWithDefaultValue );
61+ }
5462}
You can’t perform that action at this time.
0 commit comments