curator-spring-boot-starter

组件简介

基于 Apache Curator 整合的 Starter
Zookeeper 的客户端调用过于复杂,Apache Curator 就是为了简化 zookeeper 客户端调用而生,利用它,可以更好的使用 zookeeper。

使用说明

1、Spring Boot 项目添加 Maven 依赖
<dependency>
    <groupId>com.github.hiwepy</groupId>
    <artifactId>curator-spring-boot-starter</artifactId>
    <version>${project.version}</version>
</dependency>
2、在application.yml文件中增加如下配置
#################################################################################################
### Apache Curator 配置:
#################################################################################################
curator:
  connect-string: 192.168.1.1:2100,192.168.1.1:2101,192.168.1.:2102
  connection-timeout-ms: 3000
  session-timeout-ms: 30000
  max-close-wait-ms: 2000
  with-ensemble-tracker: true
3、使用示例

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CuratorApplication_Test {

    @Autowired
    private CuratorZookeeperTemplate template;

    @PostConstruct
    public void testText() {


    }

    @PostConstruct
    public void testImage() {



    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(CuratorApplication_Test.class, args);
    }

}

Jeebiz 技术社区

Jeebiz 技术社区 微信公共号小程序,欢迎关注反馈意见和一起交流,关注公众号回复「Jeebiz」拉你入群。

公共号 小程序
作者:Jeebiz  创建时间:2023-03-20 23:45
最后编辑:Jeebiz  更新时间:2024-10-04 23:38