diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLocationResolver.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLocationResolver.java index 520bd6b6..54fb8de2 100644 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLocationResolver.java +++ b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigDataLocationResolver.java @@ -84,9 +84,14 @@ public class ConsulConfigDataLocationResolver implements ConfigDataLocationResol @Override public List resolveProfileSpecific(ConfigDataLocationResolverContext resolverContext, String location, boolean optional, Profiles profiles) throws ConfigDataLocationNotFoundException { - UriComponents locationUri = parseLocation(resolverContext, location); + // create consul client + registerBean(resolverContext, ConsulProperties.class, loadProperties(resolverContext.getBinder(), locationUri)); + + registerAndPromoteBean(resolverContext, ConsulClient.class, this::createConsulClient); + + // create locations ConsulConfigProperties properties = loadConfigProperties(resolverContext.getBinder()); ConsulPropertySources consulPropertySources = new ConsulPropertySources(properties, log); @@ -95,12 +100,8 @@ public class ConsulConfigDataLocationResolver implements ConfigDataLocationResol ? consulPropertySources.getAutomaticContexts(profiles.getAccepted()) : getCustomContexts(locationUri, properties); - registerBean(resolverContext, ConsulProperties.class, loadProperties(resolverContext.getBinder(), locationUri)); - registerAndPromoteBean(resolverContext, ConsulConfigProperties.class, InstanceSupplier.of(properties)); - registerAndPromoteBean(resolverContext, ConsulClient.class, this::createConsulClient); - registerAndPromoteBean(resolverContext, ConsulConfigIndexes.class, InstanceSupplier.from(ConsulConfigDataIndexes::new));