|
|
|
@ -22,6 +22,7 @@ import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Deque;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
@ -656,27 +657,35 @@ public class ConfigFileApplicationListener
|
|
|
|
|
|
|
|
|
|
private void addLoadedPropertySources() {
|
|
|
|
|
MutablePropertySources destination = this.environment.getPropertySources();
|
|
|
|
|
String lastAdded = null;
|
|
|
|
|
List<MutablePropertySources> loaded = new ArrayList<>(this.loaded.values());
|
|
|
|
|
Collections.reverse(loaded);
|
|
|
|
|
String lastAdded = null;
|
|
|
|
|
Set<String> added = new HashSet<>();
|
|
|
|
|
for (MutablePropertySources sources : loaded) {
|
|
|
|
|
for (PropertySource<?> source : sources) {
|
|
|
|
|
if (lastAdded == null) {
|
|
|
|
|
if (destination.contains(DEFAULT_PROPERTIES)) {
|
|
|
|
|
destination.addBefore(DEFAULT_PROPERTIES, source);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
destination.addLast(source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
destination.addAfter(lastAdded, source);
|
|
|
|
|
if (added.add(source.getName())) {
|
|
|
|
|
addLoadedPropertySource(destination, lastAdded, source);
|
|
|
|
|
lastAdded = source.getName();
|
|
|
|
|
}
|
|
|
|
|
lastAdded = source.getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addLoadedPropertySource(MutablePropertySources destination,
|
|
|
|
|
String lastAdded, PropertySource<?> source) {
|
|
|
|
|
if (lastAdded == null) {
|
|
|
|
|
if (destination.contains(DEFAULT_PROPERTIES)) {
|
|
|
|
|
destination.addBefore(DEFAULT_PROPERTIES, source);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
destination.addLast(source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
destination.addAfter(lastAdded, source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|