diff --git a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperConfigProperties.java b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperConfigProperties.java index 8995032a..c5fcbc47 100644 --- a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperConfigProperties.java +++ b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperConfigProperties.java @@ -2,6 +2,7 @@ package org.springframework.cloud.zookeeper.config; import lombok.Data; +import org.hibernate.validator.constraints.NotEmpty; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -13,4 +14,10 @@ public class ZookeeperConfigProperties { private boolean enabled = true; private String root = "config"; + + @NotEmpty + private String defaultContext = "application"; + + @NotEmpty + private String profileSeparator = ","; } diff --git a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySourceLocator.java b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySourceLocator.java index 13f9f1ab..5c4405b1 100644 --- a/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySourceLocator.java +++ b/spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperPropertySourceLocator.java @@ -2,6 +2,7 @@ package org.springframework.cloud.zookeeper.config; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.annotation.PreDestroy; @@ -35,7 +36,7 @@ public class ZookeeperPropertySourceLocator implements PropertySourceLocator { String root = properties.getRoot(); List contexts = new ArrayList<>(); - String defaultContext = root + "/application"; + String defaultContext = root + "/" + properties.getDefaultContext(); contexts.add(defaultContext); addProfiles(contexts, defaultContext, profiles); @@ -45,6 +46,8 @@ public class ZookeeperPropertySourceLocator implements PropertySourceLocator { CompositePropertySource composite = new CompositePropertySource("zookeeper"); + Collections.reverse(contexts); + for (String propertySourceContext : contexts) { ZookeeperPropertySource propertySource = create(propertySourceContext); propertySource.start(); @@ -69,7 +72,7 @@ public class ZookeeperPropertySourceLocator implements PropertySourceLocator { private void addProfiles(List contexts, String baseContext, List profiles) { for (String profile : profiles) { - contexts.add(baseContext + "::" + profile); + contexts.add(baseContext + properties.getProfileSeparator() + profile); } } }