Commit b533ad3b by Dave Syer

Switch to spring.cloud.config.bootstrap.enabled=true

To enable EUreka-first bootstrap. See gh-42
parent 46e6d24a
......@@ -36,7 +36,7 @@ import com.netflix.discovery.DiscoveryClient;
*
*/
@ConditionalOnClass({ DiscoveryClient.class, ConfigServicePropertySourceLocator.class })
@ConditionalOnExpression("${spring.cloud.bootstrap.useDiscovery:false}")
@ConditionalOnExpression("${spring.cloud.config.discovery.enabled:false}")
@Configuration
@EnableEurekaClient
@Import(EurekaClientAutoConfiguration.class)
......@@ -44,8 +44,6 @@ import com.netflix.discovery.DiscoveryClient;
public class DiscoveryClientConfigServiceBootstrapConfiguration implements
ApplicationListener<ContextRefreshedEvent> {
private static final String DEFAULT_CONFIG_SERVER = "CONFIGSERVER";
@Autowired
private DiscoveryClient client;
......@@ -56,7 +54,7 @@ public class DiscoveryClientConfigServiceBootstrapConfiguration implements
public void onApplicationEvent(ContextRefreshedEvent event) {
try {
log.info("Locating configserver via discovery");
InstanceInfo server = client.getNextServerFromEureka(DEFAULT_CONFIG_SERVER,
InstanceInfo server = client.getNextServerFromEureka(delegate.getDiscovery().getServiceId(),
false);
String url = server.getHomePageUrl();
if (server.getMetadata().containsKey("password")) {
......
......@@ -62,7 +62,7 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests {
public void onWhenRequested() throws Exception {
Mockito.when(client.getNextServerFromEureka("CONFIGSERVER", false)).thenReturn(
info);
setup("spring.cloud.bootstrap.useDiscovery=true");
setup("spring.cloud.config.discovery.enabled=true");
assertEquals(
1,
context.getBeanNamesForType(DiscoveryClientConfigServiceBootstrapConfiguration.class).length);
......@@ -77,7 +77,7 @@ public class DiscoveryClientConfigServiceBootstrapConfigurationTests {
info.getMetadata().put("password", "bar");
Mockito.when(client.getNextServerFromEureka("CONFIGSERVER", false)).thenReturn(
info);
setup("spring.cloud.bootstrap.useDiscovery=true");
setup("spring.cloud.config.discovery.enabled=true");
ConfigServicePropertySourceLocator locator = context
.getBean(ConfigServicePropertySourceLocator.class);
assertEquals("http://foo:7001/", locator.getUri());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment