With latest release of Spring Cloud 2020.0 (aka Ilford) it's now easier than ever to setup Zookeeper configuration support, but the official documentation currnently lacks some straight-forward example.
Add the spring-cloud-dependencies
bom to the dependencyManagement
section of you pom.xml
<dependencyManagement>
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- ... -->
</dependencies>
</dependencyManagement>
Add the spring-cloud-starter-zookeeper-config
to your applications dependencies
<dependencies>
<!-- ... -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-config</artifactId>
</dependency>
<!-- ... -->
</dependencies>
Setup the necessary settings in your application.properties
spring.cloud.zookeeper.connect-string=your.zookeeper.location:2181
spring.cloud.zookeeper.config.root=some/config/root
spring.cloud.zookeeper.config.defaultContext=common
spring.cloud.zookeeper.config.name=my-application
spring.config.import=zookeeper: