How the Spring Boot project interfaces to the registry (ZooKeeper)

Source: Internet
Author: User
Tags zookeeper

Our registration center here is implemented using zookeeper clusters.

A Spring Boot Three-step docking ZK

The ZK client jar package is added to the 1.pom.xml file

2.Spring boot Launch class, add @enablediscoveryclient annotations

3. In the configuration file, specify the name of the microservices, ZK's connection information

Here, because we are using spring Cloud Config, in the configuration file, you only need to specify the name and Config address of the microservices, and other properties can be specified in the configuration file.

After using config, the name of the configuration file is: Bootstrap.properties (by default, the name of the configuration file is application.properties, after using config, Need to change the file name to Bootstrap.properties)

Without config, the name of the configuration file is: application.properties

Project, the contents of the Bootstrap.properties file are as follows:

On Git, the section of the configuration file for query is as follows: (Note that the file name here is: Order-test.properties, where Order is the name of the microservices, test is specified by profiles, so the same microservices, can have test, Prod,dev,local four configuration files)

How the Spring Boot project interfaces to the registry (ZooKeeper)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.