@@ -89,6 +89,7 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
89
89
90
90
String [] profileArray = parseProfiles (profiles );
91
91
List <String > apps = Arrays .asList (StringUtils .commaDelimitedListToStringArray (application .replace (" " , "" )));
92
+ Collections .reverse (apps );
92
93
if (!apps .contains (serverProperties .getDefaultApplicationName ())) {
93
94
apps = new ArrayList <>(apps );
94
95
apps .add (serverProperties .getDefaultApplicationName ());
@@ -97,7 +98,16 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
97
98
final Environment environment = new Environment (application , profileArray );
98
99
environment .setLabel (label );
99
100
100
- addPropertySources (environment , apps , profileArray , label );
101
+ List <String > labels ;
102
+ if (StringUtils .hasText (label ) && label .contains ("," )) {
103
+ labels = Arrays .asList (StringUtils .commaDelimitedListToStringArray (label ));
104
+ Collections .reverse (labels );
105
+ }
106
+ else {
107
+ labels = Collections .singletonList (label );
108
+ }
109
+
110
+ addPropertySources (environment , apps , profileArray , labels );
101
111
102
112
if (LOG .isDebugEnabled ()) {
103
113
LOG .debug ("Returning Environment: " + environment );
@@ -106,25 +116,36 @@ public Environment findOne(String specifiedApplication, String specifiedProfiles
106
116
return environment ;
107
117
}
108
118
109
- private void addPropertySources (Environment environment , List <String > apps , String [] profiles , String label ) {
110
- // If we have profiles, add property sources with those profiles
111
- for (String profile : profiles ) {
112
- addPropertySourcesForApps (apps , app -> addProfileSpecificPropertySource (environment , app , profile , label ));
119
+ private void addPropertySources (Environment environment , List <String > apps , String [] profiles ,
120
+ List <String > labels ) {
121
+ for (String label : labels ) {
122
+ // If we have profiles, add property sources with those profiles
123
+ for (String profile : profiles ) {
124
+ addPropertySourcesForApps (apps ,
125
+ app -> addProfileSpecificPropertySource (environment , app , profile , label ));
126
+ }
113
127
}
114
128
115
129
// If we have no profiles just add property sources for all apps
116
130
if (profiles .length == 0 ) {
117
- addPropertySourcesForApps (apps , app -> addNonProfileSpecificPropertySource (environment , app , null , label ));
131
+ for (String label : labels ) {
132
+ addPropertySourcesForApps (apps ,
133
+ app -> addNonProfileSpecificPropertySource (environment , app , null , label ));
134
+ }
118
135
}
119
136
else {
120
- // If we have profiles, we still need to add property sources from files that
121
- // are not profile specific but we pass
122
- // along the profiles as well so we can check if any non-profile specific YAML
123
- // files have profile specific documents
124
- // within them
125
- for (String profile : profiles ) {
126
- addPropertySourcesForApps (apps ,
127
- app -> addNonProfileSpecificPropertySource (environment , app , profile , label ));
137
+ for (String label : labels ) {
138
+ // If we have profiles, we still need to add property sources from files
139
+ // that
140
+ // are not profile specific but we pass
141
+ // along the profiles as well so we can check if any non-profile specific
142
+ // YAML
143
+ // files have profile specific documents
144
+ // within them
145
+ for (String profile : profiles ) {
146
+ addPropertySourcesForApps (apps ,
147
+ app -> addNonProfileSpecificPropertySource (environment , app , profile , label ));
148
+ }
128
149
}
129
150
}
130
151
}
0 commit comments