Fixed inconsistency in the dependencies approach
This commit is contained in:
@@ -96,8 +96,8 @@ You can also benefit from the Zookeeper Dependency Watchers functionality that l
|
||||
=== How to activate Zookeeper Dependencies
|
||||
|
||||
- Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.
|
||||
- In addition to that you have to set the property `spring.cloud.zookeeper.dependency.enabled` to true (defaults to `true` if not set explicitly).
|
||||
- You have to have the `spring.cloud.zookeeper.dependencies` section properly set up - check the subsequent section for more details.
|
||||
- If you have to have the `spring.cloud.zookeeper.dependencies` section properly set up - check the subsequent section for more details then the feature is active
|
||||
- You can have the dependencies turned off even if you've provided the dependencies in your properties. Just set the property `spring.cloud.zookeeper.dependency.enabled` to false (defaults to `true`).
|
||||
|
||||
=== Setting up Zookeeper Dependencies
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
/**
|
||||
@@ -34,6 +33,5 @@ import org.springframework.context.annotation.Conditional;
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Conditional(DependenciesPassedCondition.class)
|
||||
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.enabled", matchIfMissing = true)
|
||||
public @interface ConditionalOnDependenciesPassed {
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DependenciesPassedCondition extends SpringBootCondition {
|
||||
return ConditionOutcome.match("Dependencies are defined in configuration");
|
||||
}
|
||||
Boolean dependenciesEnabled = context.getEnvironment()
|
||||
.getProperty("spring.cloud.zookeeper.dependency.enabled", Boolean.class, true);
|
||||
.getProperty("spring.cloud.zookeeper.dependency.enabled", Boolean.class, false);
|
||||
if (dependenciesEnabled) {
|
||||
return ConditionOutcome.match("Dependencies are not defined in configuration, but switch is turned on");
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ZookeeperLifecycleRegistrationDisabledTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
List<ServiceInstance> instances = client.getInstances("myTestNotRegisteredService");
|
||||
List<ServiceInstance> instances = this.client.getInstances("myTestNotRegisteredService");
|
||||
assertTrue("service was registered", instances.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user