zoukankan      html  css  js  c++  java
  • nacos 注册服务提供者

    1:pom

      1.1:父pom

      <!--Spring cloud alibaba dependencies -->
                <dependency>
                    <groupId>com.alibaba.cloud</groupId>
                    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                    <version>${spring.cloud.alibaba.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
                <!--   nacos    -->
                <dependency>
                    <groupId>com.alibaba.cloud</groupId>
                    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
                    <version>${nacos-version}</version>
                </dependency>

      1.2:项目pom

            <!--  spring-cloud-alibaba  -->
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${alibaba-dependencies-version}</version>
                <type>pom</type>
            </dependency>
    
            <!-- nacos-discovery -->
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            </dependency>

    2:yml

    server:
      port: 9001  #服务端口号
    
    spring:
      application:
        name: nacos-payment-provider   # 也是注册到 nacos 服务的名称( 服务别名(使用服务别名去注册中心获取实际的RPC远程调用地址) )
      cloud:
        nacos:
          discovery:
            server-addr: 127.0.0.1:8848
            
    management:
      endpoints:
        web:
          exposure:
            include: '*'

    3:注解

    @EnableDiscoveryClient
    @SpringBootApplication
    public class Paytment9001 {
    
        public static void main(String[] args) {
            SpringApplication.run(Paytment9001.class);
        }
    }

    分配端口:9001 9002  9003

  • 相关阅读:
    VC环境OpenSSL编译笔记
    手动造工具TaskJobManage
    Java性能分析工具
    ES77
    Flink消费kafka
    阻塞对列
    C# 超时事件
    毕业前做一件事
    PID控制器——控制网络爬虫速度
    2.5 OpenEuler 中C与汇编的混合编程(选做)
  • 原文地址:https://www.cnblogs.com/draymond/p/12719545.html
Copyright © 2011-2022 走看看