From 336877934f1ef32df46c4343f21ef2f674a6ff5d Mon Sep 17 00:00:00 2001 From: Ryan Baxter <524254+ryanjbaxter@users.noreply.github.com> Date: Thu, 15 Jun 2023 08:53:16 -0400 Subject: [PATCH] Create ConsulFunction properly to avoid ClassNotFoundException --- .../configclient/ConsulConfigServerBootstrapper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/configclient/ConsulConfigServerBootstrapper.java b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/configclient/ConsulConfigServerBootstrapper.java index 725537c9..5debe875 100644 --- a/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/configclient/ConsulConfigServerBootstrapper.java +++ b/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/discovery/configclient/ConsulConfigServerBootstrapper.java @@ -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 apply(String serviceId) { return apply(serviceId, null, null, null);