From dc556087d2560736bf7f76c3167efc68ec8e0a57 Mon Sep 17 00:00:00 2001 From: yh <1844516659@qq.com> Date: Thu, 14 Jul 2022 12:05:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9E=E6=BB=B4=E5=87=BA=E8=A1=8C=E7=BD=91?= =?UTF-8?q?=E7=BA=A6=E8=BD=A62022-Alibaba=20Nacos=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=90=AD=E5=BB=BA&=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-passenger/pom.xml | 8 ++++++++ .../apipassenger/ApiPassengerApplication.java | 2 ++ api-passenger/src/main/resources/application.yml | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/api-passenger/pom.xml b/api-passenger/pom.xml index 1fa622f..7e59b0d 100644 --- a/api-passenger/pom.xml +++ b/api-passenger/pom.xml @@ -17,6 +17,14 @@ org.springframework.boot spring-boot-starter-web + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + 2021.1 + + \ No newline at end of file diff --git a/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java b/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java index 382d7b5..06ff16e 100644 --- a/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java +++ b/api-passenger/src/main/java/com/mashibing/apipassenger/ApiPassengerApplication.java @@ -2,8 +2,10 @@ package com.mashibing.apipassenger; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication +@EnableDiscoveryClient public class ApiPassengerApplication { public static void main(String[] args) { diff --git a/api-passenger/src/main/resources/application.yml b/api-passenger/src/main/resources/application.yml index 54b155f..bb8fa7f 100644 --- a/api-passenger/src/main/resources/application.yml +++ b/api-passenger/src/main/resources/application.yml @@ -1,2 +1,11 @@ server: - port: 8081 \ No newline at end of file + port: 8081 + +# nacos 服务发现 +spring: + application: + name: api-passenger + cloud: + nacos: + discovery: + server-addr: 127.0.0.1:8848 \ No newline at end of file