Use spring-config-import in configserver (#1258)

Co-authored-by: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com>
This commit is contained in:
Ryan Baxter
2023-03-15 10:03:38 -04:00
committed by GitHub
parent 8cb2d49058
commit 610c6ffb75
4 changed files with 16 additions and 5 deletions

View File

@@ -264,8 +264,12 @@ public final class ConfigUtils {
public static <T> void registerSingle(ConfigurableBootstrapContext bootstrapContext, Class<T> cls, T instance,
String name) {
bootstrapContext.registerIfAbsent(cls, BootstrapRegistry.InstanceSupplier.of(instance));
bootstrapContext.addCloseListener(event -> event.getApplicationContext().getBeanFactory()
.registerSingleton(name, event.getBootstrapContext().get(cls)));
bootstrapContext.addCloseListener(event -> {
if (event.getApplicationContext().getBeanFactory().getSingleton(name) == null) {
event.getApplicationContext().getBeanFactory().registerSingleton(name,
event.getBootstrapContext().get(cls));
}
});
}
/**