<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                步驟如下: **1. 構建消費端模塊:cloud-comsumerzk-order80** **2. 當前模塊添加 zookeeper-discovery 依賴** ```xml <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> ... </dependencies> ``` **3. 在當前模塊的`application.yml`配置 zookeeper 相關** ```yml server: port: 80 spring: application: name: cloud-comsumer-order cloud: zookeeper: #zookeeper地址 connect-string: 192.168.1.17:2181 ``` **4. 在當前啟動類上標注注解`@EnableDiscoveryClient`** ```java @SpringBootApplication @EnableDiscoveryClient public class OrderZKMain80 { public static void main(String[] args) { SpringApplication.run(OrderZKMain80.class, args); } } ``` **5. 在當前模塊注入 RestTemplate 組件方便訪問服務端** ```java @Configuration public class ApplicationContextConfig { @Bean @LoadBalanced public RestTemplate getRestTemplate() { return new RestTemplate(); } } ``` **6. 當前模塊的 controller 層** ```java @RestController @RequestMapping("/comsumer") public class OrderController { @Resource private RestTemplate restTemplate; //cloud-payment-service 為服務端的 spring.application.name 配置 public static final String PAYENT_URL = "http://cloud-payment-service"; @GetMapping("/payment/zk") public String getpaymentInfo() { String res = restTemplate.getForObject(PAYENT_URL + "/payment/zk", String.class); return res; } } ``` **7. 測試** (1)啟動 Zookeeper。 ```shell # zkServer.sh start # jps 2621 QuorumPeerMain --出現該進行則啟動成功 ``` 記住需要到 Linux 中關閉防火墻,外面應用才可以訪問到 Zookeeper。 ```shell -- 關閉防火墻 # systemctl stop firewalld --查看防火墻是否關閉 # firewall-cmd --state not running -- 禁止防火墻開機自啟動 # systemctl disable firewalld.service ``` (2)啟動服務端模塊、消費端模塊。 訪問消費端模塊:http://localhost:80/comsumer/payment/zk 。得到如下響應。 ``` serverPort:8004 ``` (3)到 Zookeeper 中查看消費端的注冊信息。 ```shell --切換到 Zookeeper 的安裝目錄 # cd /opt/install/zookeeper --啟動 zookeeper 客戶端工具 # bin/zkCli.sh --查看 zookeeper 節點 [zk: localhost:2181(CONNECTED) 16] ls / [services, zookeeper] [zk: localhost:2181(CONNECTED) 17] ls /services [cloud-comsumer-order, cloud-payment-service] [zk: localhost:2181(CONNECTED) 18] ls /services/cloud-comsumer-order [476aad5c-4f02-44b2-b42d-741bea0ed116] --獲取節點信息 [zk: localhost:2181(CONNECTED) 19] get /services/cloud-comsumer-order/476aad5c-4f02-44b2-b42d-741bea0ed116 {"name":"cloud-comsumer-order","id":"476aad5c-4f02-44b2-b42d-741 ``` 完整的注冊信息如下: ```json { "name":"cloud-comsumer-order", "id":"476aad5c-4f02-44b2-b42d-741bea0ed116", "address":"USER-20210829ES", "port":80, "sslPort":null, "payload":{ "@class":"org.springframework.cloud.zookeeper.discovery.ZookeeperInstance", "id":"application-1", "name":"cloud-comsumer-order", "metadata":{ } }, "registrationTimeUTC":1637399316399, "serviceType":"DYNAMIC", "uriSpec":{ "parts":[ { "value":"scheme", "variable":true }, { "value":"://", "variable":false }, { "value":"address", "variable":true }, { "value":":", "variable":false }, { "value":"port", "variable":true } ] } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看