This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new a41fab1  basic demo add nacos support (#109)
a41fab1 is described below

commit a41fab1dc35d8e342c29297d42b91ca713f8aad0
Author: liubao68 <[email protected]>
AuthorDate: Mon Oct 23 15:20:42 2023 +0800

    basic demo add nacos support (#109)
---
 basic/consumer/src/main/resources/application.yml | 32 +++++++++++++++-
 basic/gateway/src/main/resources/application.yml  | 38 ++++++++++++++++---
 basic/pom.xml                                     | 46 ++++++++++++++++++-----
 basic/provider/src/main/resources/application.yml | 30 ++++++++++++++-
 4 files changed, 128 insertions(+), 18 deletions(-)

diff --git a/basic/consumer/src/main/resources/application.yml 
b/basic/consumer/src/main/resources/application.yml
index 04ecf04..597b7df 100644
--- a/basic/consumer/src/main/resources/application.yml
+++ b/basic/consumer/src/main/resources/application.yml
@@ -20,11 +20,39 @@ servicecomb:
     application: basic-application
     name: consumer
     version: 0.0.1
+
+  rest:
+    address: 0.0.0.0:9092
+
+spring:
+  profiles:
+    active: servicecomb # 注册中心类型:servicecomb 或者 nacos
+
+---
+spring:
+  config:
+    activate:
+      on-profile: servicecomb
+servicecomb:
+  # 注册发现
   registry:
     sc:
       address: http://localhost:30100
+  # 动态配置
   kie:
     serverUri: http://localhost:30110
 
-  rest:
-    address: 0.0.0.0:9092
+---
+spring:
+  config:
+    activate:
+      on-profile: nacos
+servicecomb:
+  # 注册发现
+  registry:
+    nacos:
+      serverAddr: http://localhost:8848
+  # 动态配置
+  nacos:
+    serverAddr: http://localhost:8848
+
diff --git a/basic/gateway/src/main/resources/application.yml 
b/basic/gateway/src/main/resources/application.yml
index 36dc3b9..6d5a5be 100644
--- a/basic/gateway/src/main/resources/application.yml
+++ b/basic/gateway/src/main/resources/application.yml
@@ -20,11 +20,6 @@ servicecomb:
     application: basic-application
     name: gateway
     version: 0.0.1
-  registry:
-    sc:
-      address: http://localhost:30100
-  kie:
-    serverUri: http://localhost:30110
 
   rest:
     address: 0.0.0.0:9090?sslEnabled=false
@@ -43,3 +38,36 @@ servicecomb:
               path: "/.*"
               microserviceName: consumer
               versionRule: 0.0.0+
+
+spring:
+  profiles:
+    active: servicecomb # 注册中心类型:servicecomb 或者 nacos
+
+---
+spring:
+  config:
+    activate:
+      on-profile: servicecomb
+servicecomb:
+  # 注册发现
+  registry:
+    sc:
+      address: http://localhost:30100
+  # 动态配置
+  kie:
+    serverUri: http://localhost:30110
+
+---
+spring:
+  config:
+    activate:
+      on-profile: nacos
+servicecomb:
+  # 注册发现
+  registry:
+    nacos:
+      serverAddr: http://localhost:8848
+  # 动态配置
+  nacos:
+    serverAddr: http://localhost:8848
+
diff --git a/basic/pom.xml b/basic/pom.xml
index c318565..9555036 100644
--- a/basic/pom.xml
+++ b/basic/pom.xml
@@ -49,15 +49,6 @@
       <groupId>org.apache.servicecomb</groupId>
       <artifactId>solution-basic</artifactId>
     </dependency>
-    <!-- using service-center & kie -->
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>registry-service-center</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>config-kie</artifactId>
-    </dependency>
     <!-- using log4j2 -->
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
@@ -73,6 +64,43 @@
     </dependency>
   </dependencies>
 
+  <profiles>
+    <profile>
+      <id>servicecomb</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <dependencies>
+        <!-- using service-center & kie -->
+        <dependency>
+          <groupId>org.apache.servicecomb</groupId>
+          <artifactId>registry-service-center</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.servicecomb</groupId>
+          <artifactId>config-kie</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>nacos</id>
+      <activation>
+        <activeByDefault>false</activeByDefault>
+      </activation>
+      <dependencies>
+        <!-- using service-center & kie -->
+        <dependency>
+          <groupId>org.apache.servicecomb</groupId>
+          <artifactId>registry-nacos</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.servicecomb</groupId>
+          <artifactId>config-nacos</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+
   <modules>
     <module>provider</module>
     <module>consumer</module>
diff --git a/basic/provider/src/main/resources/application.yml 
b/basic/provider/src/main/resources/application.yml
index e33fd92..939720b 100644
--- a/basic/provider/src/main/resources/application.yml
+++ b/basic/provider/src/main/resources/application.yml
@@ -20,12 +20,38 @@ servicecomb:
     application: basic-application
     name: provider
     version: 0.0.1
+  rest:
+    address: 0.0.0.0:9093
+
+spring:
+  profiles:
+    active: servicecomb # 注册中心类型:servicecomb 或者 nacos
 
+---
+spring:
+  config:
+    activate:
+      on-profile: servicecomb
+servicecomb:
+  # 注册发现
   registry:
     sc:
       address: http://localhost:30100
+  # 动态配置
   kie:
     serverUri: http://localhost:30110
 
-  rest:
-    address: 0.0.0.0:9093
+---
+spring:
+  config:
+    activate:
+      on-profile: nacos
+servicecomb:
+  # 注册发现
+  registry:
+    nacos:
+      serverAddr: http://localhost:8848
+  # 动态配置
+  nacos:
+    serverAddr: http://localhost:8848
+

Reply via email to