Create ConsulFunction properly to avoid ClassNotFoundException

This commit is contained in:
Ryan Baxter
2023-06-15 08:53:16 -04:00
parent a9b4d440c5
commit 336877934f

View File

@@ -93,7 +93,7 @@ public class ConsulConfigServerBootstrapper implements BootstrapRegistryInitiali
// ConfigServerInstanceProvider.Function
// which would result in a ClassNotFoundException when Spring Cloud Config is not
// on the classpath
registry.registerIfAbsent(ConfigServerInstanceProvider.Function.class, ConsulFunction::new);
registry.registerIfAbsent(ConfigServerInstanceProvider.Function.class, ConsulFunction::create);
}
private BindHandler getBindHandler(org.springframework.boot.BootstrapContext context) {
@@ -126,6 +126,10 @@ public class ConsulConfigServerBootstrapper implements BootstrapRegistryInitiali
this.context = context;
}
public static ConsulFunction create(BootstrapContext context) {
return new ConsulFunction(context);
}
@Override
public List<ServiceInstance> apply(String serviceId) {
return apply(serviceId, null, null, null);