天天看點

阿裡 Nacos 注冊中心 配置啟動說明

1.控制台,服務端

下載下傳nacos運作包,找到 nacos\bin\startup.cmd

輕按兩下 startup.cmd 運作, 預設使用者名密碼都是 nacos

2. 客戶的配置,微服務中配置

pom

<dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>      
  1. 主啟動類加上注解

    @EnableDiscoveryClient

  2. 例如
@EnableDiscoveryClient
@SpringBootApplication
public class PaymentMain9001 {
    //from fhadmin.cn
    public static void main(String[] args) {
        SpringApplication.run(PaymentMain9001.class, args);
    }
 
}      
  1. yml 配置檔案
server:
  port: 9001
 
 
spring:
  application:
    name: nacos-payment-provider
  cloud:
    nacos:
      discovery:
        server-addr: 120.92.164.250:8848  #配置的Nacos位址(本機的寫localhost:8848,伺服器的寫IP位址)
 
 
management:
  endpoints:
    web:
      exposure:
        include: '*'