Browse Source

使用 nacos 替换 eureka 作为 springcloud 的服务发现

reghao 1 month ago
parent
commit
f137f8fcea
36 changed files with 288 additions and 163 deletions
  1. 3 2
      account/account-service/pom.xml
  2. 6 5
      account/account-service/src/main/resources/application-dev.yml
  3. 6 5
      account/account-service/src/main/resources/application-test.yml
  4. 1 7
      account/account-service/src/main/resources/application.yml
  5. 3 2
      admin/pom.xml
  6. 12 12
      admin/src/main/java/cn/reghao/tnb/admin/service/TnbEurekaService.java
  7. 6 5
      admin/src/main/resources/application-dev.yml
  8. 6 5
      admin/src/main/resources/application-test.yml
  9. 0 6
      admin/src/main/resources/application.yml
  10. 3 2
      content/content-service/pom.xml
  11. 18 0
      content/content-service/src/main/java/cn/reghao/tnb/content/app/media/TranscodeTask.java
  12. 47 0
      content/content-service/src/main/java/cn/reghao/tnb/content/app/media/VideoConsumer.java
  13. 61 0
      content/content-service/src/main/java/cn/reghao/tnb/content/app/media/VideoProducer.java
  14. 6 5
      content/content-service/src/main/resources/application-dev.yml
  15. 6 5
      content/content-service/src/main/resources/application-test.yml
  16. 0 6
      content/content-service/src/main/resources/application.yml
  17. 3 2
      file/file-service/pom.xml
  18. 6 5
      file/file-service/src/main/resources/application-dev.yml
  19. 6 5
      file/file-service/src/main/resources/application-test.yml
  20. 0 6
      file/file-service/src/main/resources/application.yml
  21. 17 8
      file/file-service/src/test/java/DiskUnitTest.java
  22. 14 0
      gateway/pom.xml
  23. 9 5
      gateway/src/main/resources/application-dev.yml
  24. 6 5
      gateway/src/main/resources/application-test.yml
  25. 0 6
      gateway/src/main/resources/application.yml
  26. 3 2
      message/message-service/pom.xml
  27. 6 5
      message/message-service/src/main/resources/application-dev.yml
  28. 6 5
      message/message-service/src/main/resources/application-test.yml
  29. 0 6
      message/message-service/src/main/resources/application.yml
  30. 3 2
      search/search-service/pom.xml
  31. 5 8
      search/search-service/src/main/resources/application-dev.yml
  32. 5 8
      search/search-service/src/main/resources/application-test.yml
  33. 3 2
      user/user-service/pom.xml
  34. 6 5
      user/user-service/src/main/resources/application-dev.yml
  35. 6 5
      user/user-service/src/main/resources/application-test.yml
  36. 0 6
      user/user-service/src/main/resources/application.yml

+ 3 - 2
account/account-service/pom.xml

@@ -92,8 +92,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
 
         <dependency>

+ 6 - 5
account/account-service/src/main/resources/application-dev.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -21,8 +26,4 @@ spring:
   datasource:
     url: jdbc:mysql://127.0.0.1/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Dev@123456

+ 6 - 5
account/account-service/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -21,8 +26,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.209:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 1 - 7
account/account-service/src/main/resources/application.yml

@@ -68,10 +68,4 @@ mybatis:
     map-underscore-to-camel-case: true
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
   mapper-locations: classpath*:mapper/**/**.xml
-  type-aliases-package: cn.reghao.tnb.account.app.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
+  type-aliases-package: cn.reghao.tnb.account.app.model.po

+ 3 - 2
admin/pom.xml

@@ -136,8 +136,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
 
         <dependency>

+ 12 - 12
admin/src/main/java/cn/reghao/tnb/admin/service/TnbEurekaService.java

@@ -3,8 +3,8 @@ package cn.reghao.tnb.admin.service;
 import cn.reghao.jutil.jdk.converter.DateTimeConverter;
 import cn.reghao.tnb.admin.model.vo.EurekaInstance;
 import cn.reghao.tnb.admin.model.vo.EurekaService;
-import com.netflix.discovery.EurekaClient;
-import com.netflix.discovery.shared.Applications;
+//import com.netflix.discovery.EurekaClient;
+//import com.netflix.discovery.shared.Applications;
 import org.springframework.cloud.client.discovery.DiscoveryClient;
 import org.springframework.stereotype.Service;
 
@@ -17,16 +17,16 @@ import java.util.*;
 @Service
 public class TnbEurekaService {
     private final DiscoveryClient discoveryClient;
-    private final EurekaClient eurekaClient;
+    //private final EurekaClient eurekaClient;
 
-    public TnbEurekaService(DiscoveryClient discoveryClient, EurekaClient eurekaClient) {
+    public TnbEurekaService(DiscoveryClient discoveryClient/*, EurekaClient eurekaClient*/) {
         this.discoveryClient = discoveryClient;
-        this.eurekaClient = eurekaClient;
+        //this.eurekaClient = eurekaClient;
     }
 
     public List<EurekaInstance> getRegistryServices() {
         List<EurekaInstance> list = new ArrayList<>();
-        Applications applications = eurekaClient.getApplications();
+        /*Applications applications = eurekaClient.getApplications();
         applications.getRegisteredApplications().forEach(application -> {
             String name = application.getName();
             application.getInstances().forEach(instanceInfo -> {
@@ -41,13 +41,13 @@ public class TnbEurekaService {
                 String dirtyTimeStr = DateTimeConverter.msTimestamp(dirtyTime);
                 list.add(new EurekaInstance(instanceId, appName, hostPort, updateTimeStr, dirtyTimeStr));
             });
-        });
+        });*/
 
         return list;
     }
 
     public List<EurekaService> getServiceList() {
-        Map<String, List<EurekaInstance>> serviceMap = new HashMap<>();
+        /*Map<String, List<EurekaInstance>> serviceMap = new HashMap<>();
         Applications applications = eurekaClient.getApplications();
         applications.getRegisteredApplications().forEach(application -> {
             String name = application.getName();
@@ -64,18 +64,18 @@ public class TnbEurekaService {
                 String dirtyTimeStr = DateTimeConverter.msTimestamp(dirtyTime);
                 serviceInstances.add(new EurekaInstance(instanceId, appName, hostPort, updateTimeStr, dirtyTimeStr));
             });
-        });
+        });*/
 
         List<EurekaService> serviceList = new ArrayList<>();
-        serviceMap.forEach((name, instanceList) -> {
+        /*serviceMap.forEach((name, instanceList) -> {
             int total = instanceList.size();
             serviceList.add(new EurekaService(name, total, instanceList));
-        });
+        });*/
         return serviceList;
     }
 
     public void getServices() {
         List<String> list = discoveryClient.getServices();
-        eurekaClient.getApplicationInfoManager();
+        //eurekaClient.getApplicationInfoManager();
     }
 }

+ 6 - 5
admin/src/main/resources/application-dev.yml

@@ -5,6 +5,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     mongodb:
       uri: mongodb://test:Test_123456@192.168.0.214:27017,192.168.0.215:27017,192.168.0.216:27017/tnb_content_rdb?replicaSet=mymongo&authSource=admin&readPreference=secondaryPreferred&connectTimeoutMS=300000
@@ -36,8 +41,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.215:3306,192.168.0.216:3306/testdb?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Test@123456

+ 6 - 5
admin/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -21,8 +26,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.209:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 0 - 6
admin/src/main/resources/application.yml

@@ -47,12 +47,6 @@ mybatis:
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
   mapper-locations: classpath*:mapper/**/**.xml
   type-aliases-package: cn.reghao.tnb.admin.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 app:
   es-host: 192.168.0.81
   es-port: 9200

+ 3 - 2
content/content-service/pom.xml

@@ -123,8 +123,9 @@
             </exclusions>
         </dependency>-->
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
         <!--<dependency>
             <groupId>org.springframework.cloud</groupId>

+ 18 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/media/TranscodeTask.java

@@ -0,0 +1,18 @@
+package cn.reghao.tnb.content.app.media;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2026-02-12 21:24:35
+ */
+@Data
+public class TranscodeTask {
+    private String videoId;      // 原视频ID
+    private String sourcePath;   // 原始存储路径
+    private int segmentCount;    // 总切片数
+    private int completedCount;  // 已完成切片数
+    private List<String> partPaths; // 各个子片段的路径
+}

+ 47 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/media/VideoConsumer.java

@@ -0,0 +1,47 @@
+package cn.reghao.tnb.content.app.media;
+
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+/**
+ * @author reghao
+ * @date 2026-02-12 21:25:16
+ */
+@Component
+public class VideoConsumer {
+    private final RedisTemplate redisTemplate;
+
+    public VideoConsumer(RedisTemplate redisTemplate) {
+        this.redisTemplate = redisTemplate;
+    }
+
+    @RabbitListener(queues = "transcoding_queue")
+    public void handleTranscode(Map<String, Object> message) {
+        String partPath = (String) message.get("partPath");
+        String videoId = (String) message.get("videoId");
+
+        // 执行转码命令:ffmpeg -i part.mp4 -c:v libx265 ... out.mp4
+        boolean success = executeFFmpegTranscode(partPath);
+
+        if (success) {
+            // 更新 Redis 中的计数器
+            Long completed = redisTemplate.opsForHash().increment("v_status:" + videoId, "done", 1);
+            Long total = (Long) redisTemplate.opsForHash().get("v_status:" + videoId, "total");
+
+            // 检查是否所有切片都转完了
+            if (completed.equals(total)) {
+                notifyMergeService(videoId); // 触发合并或生成 m3u8
+            }
+        }
+    }
+
+    private boolean executeFFmpegTranscode(String path) {
+        return false;
+    }
+
+    private void notifyMergeService(String videoId) {
+    }
+}

+ 61 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/media/VideoProducer.java

@@ -0,0 +1,61 @@
+package cn.reghao.tnb.content.app.media;
+
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.stereotype.Component;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author reghao
+ * @date 2026-02-12 21:25:10
+ */
+@Component
+public class VideoProducer {
+    private RabbitTemplate rabbitTemplate;
+
+    public VideoProducer(RabbitTemplate rabbitTemplate) {
+        this.rabbitTemplate = rabbitTemplate;
+    }
+
+    public List<String> splitVideo(String inputPath, String outputFolder) throws Exception {
+        // 命令:ffmpeg -i in.mp4 -f segment -segment_time 300 -c copy out/part_%03d.mp4
+        List<String> commands = Arrays.asList(
+                "ffmpeg", "-i", inputPath,
+                "-f", "segment",
+                "-segment_time", "300",
+                "-c", "copy",
+                outputFolder + "/part_%03d.mp4"
+        );
+
+        ProcessBuilder pb = new ProcessBuilder(commands);
+        Process process = pb.start();
+        int exitCode = process.waitFor();
+
+        if (exitCode == 0) {
+            // 返回生成的子文件路径列表
+            return Files.list(Paths.get(outputFolder))
+                    .map(Path::toString)
+                    .collect(Collectors.toList());
+        }
+        throw new RuntimeException("切片失败");
+    }
+
+    public void dispatchParts(TranscodeTask task) {
+        for (int i = 0; i < task.getPartPaths().size(); i++) {
+            Map<String, Object> message = new HashMap<>();
+            message.put("videoId", task.getVideoId());
+            message.put("partPath", task.getPartPaths().get(i));
+            message.put("index", i);
+
+            // 发送到转码队列,由多个 Worker 节点消费
+            rabbitTemplate.convertAndSend("transcoding_exchange", "part_routing_key", message);
+        }
+    }
+}

+ 6 - 5
content/content-service/src/main/resources/application-dev.yml

@@ -8,6 +8,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -19,8 +24,4 @@ spring:
     port: 5672
     virtual-host: /
     username: dev
-    password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Dev@123456

+ 6 - 5
content/content-service/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -17,8 +22,4 @@ spring:
     port: 5672
     virtual-host: /
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 0 - 6
content/content-service/src/main/resources/application.yml

@@ -36,12 +36,6 @@ mybatis:
     map-underscore-to-camel-case: true
   mapper-locations: classpath*:mapper/**.xml
   type-aliases-package: cn.reghao.tnb.content.app.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 feign:
   circuitbreaker:
     enabled: true

+ 3 - 2
file/file-service/pom.xml

@@ -103,8 +103,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
 
         <dependency>

+ 6 - 5
file/file-service/src/main/resources/application-dev.yml

@@ -8,6 +8,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -17,8 +22,4 @@ spring:
   datasource:
     url: jdbc:mysql://127.0.0.1/tnb_content_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Dev@123456

+ 6 - 5
file/file-service/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -15,8 +20,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.209:3306/tnb_content_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 0 - 6
file/file-service/src/main/resources/application.yml

@@ -42,11 +42,5 @@ mybatis:
     map-underscore-to-camel-case: true
   mapper-locations: classpath*:mapper/**.xml
   type-aliases-package: cn.reghao.tnb.file.app.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 app:
   baseDir: /opt/data/tnbfile

+ 17 - 8
file/file-service/src/test/java/DiskUnitTest.java

@@ -1,3 +1,5 @@
+import cn.reghao.jutil.jdk.converter.ByteConverter;
+import cn.reghao.jutil.jdk.converter.ByteType;
 import cn.reghao.tnb.file.app.zdisk.model.vo.FileTree;
 import cn.reghao.tnb.oss.api.constant.ObjectType;
 import net.sourceforge.tess4j.Tesseract;
@@ -91,16 +93,23 @@ public class DiskUnitTest {
 
     @Test
     public void ocrTest() throws Exception {
-        Tesseract tess = new Tesseract();
-        // 字库位置
-        tess.setDatapath("/home/reghao/Downloads/tess");
-        // 中英文混合
-        tess.setLanguage("eng+chi_sim");
+//        Tesseract tess = new Tesseract();
+//        // 字库位置
+//        tess.setDatapath("/home/reghao/Downloads/tess");
+//        // 中英文混合
+//        tess.setLanguage("eng+chi_sim");
         //tess.setLanguage("chi_sim");
 //        tess.setLanguage("eng");
 
-        String imagePath = "/home/reghao/Downloads/1620438.png";
-        String result = tess.doOCR(new File(imagePath));
-        System.out.println(result);
+//        String imagePath = "/home/reghao/Downloads/1620438.png";
+//        String result = tess.doOCR(new File(imagePath));
+//        System.out.println(result);
+
+        ByteConverter byteConverter = new ByteConverter();
+        long value = 1623581261432L;
+        value = 945039537733L;
+
+        String str = byteConverter.convert(ByteType.Bytes, value);
+        System.out.println(str);
     }
 }

+ 14 - 0
gateway/pom.xml

@@ -44,8 +44,22 @@
         </dependency>
 
         <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>33.0.0-jre</version>
+        </dependency>
+        <!--<dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
 
         <dependency>

+ 9 - 5
gateway/src/main/resources/application-dev.yml

@@ -8,13 +8,17 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848 # Nacos 服务器地址
+        # 开启鉴权后必须配置以下信息
+        username: nacos
+        password: E4B2M7W8Dx
+        # 如果使用了命名空间,请填写 Namespace ID (注意是 ID 不是名称)
+        # namespace: "your-namespace-id"
   data:
     redis:
       database: 0
       host: 127.0.0.1
       port: 6379
-      password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+      password: Dev@123456

+ 6 - 5
gateway/src/main/resources/application-test.yml

@@ -8,13 +8,14 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
       host: 192.168.0.209
       port: 6379
-      password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+      password: Test@123456

+ 0 - 6
gateway/src/main/resources/application.yml

@@ -206,12 +206,6 @@ spring:
 #            allowedOrigins: "*"
 #            allowedMethods: "*"
 #            allowedHeaders: "*"
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 app:
   resources:
     _api_admin_: role_tnb_admin

+ 3 - 2
message/message-service/pom.xml

@@ -82,8 +82,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
         <!--<dependency>
             <groupId>org.springframework.cloud</groupId>

+ 6 - 5
message/message-service/src/main/resources/application-dev.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -21,8 +26,4 @@ spring:
   datasource:
     url: jdbc:mysql://127.0.0.1/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Dev@123456

+ 6 - 5
message/message-service/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -21,8 +26,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.209:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 0 - 6
message/message-service/src/main/resources/application.yml

@@ -24,12 +24,6 @@ mybatis:
     map-underscore-to-camel-case: true
   mapper-locations: classpath*:mapper/**/**.xml
   type-aliases-package: cn.reghao.tnb.account.app.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 hystrix:
   dashboard:
     proxy-stream-allow-list: "127.0.0.1"

+ 3 - 2
search/search-service/pom.xml

@@ -191,8 +191,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
 
         <!--<dependency>

+ 5 - 8
search/search-service/src/main/resources/application-dev.yml

@@ -49,6 +49,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     mongodb:
       host: 127.0.0.1
@@ -67,14 +72,6 @@ spring:
     virtual-host: /
     username: dev
     password: Dev@123456
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
 app:
   es-host: 192.168.0.81
   es-port: 9200

+ 5 - 8
search/search-service/src/main/resources/application-test.yml

@@ -49,6 +49,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     mongodb:
       host: 192.168.0.209
@@ -67,14 +72,6 @@ spring:
     virtual-host: /
     username: test
     password: Test@123456
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
 app:
   es-host: 192.168.0.81
   es-port: 9200

+ 3 - 2
user/user-service/pom.xml

@@ -75,8 +75,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+            <version>2023.0.1.0</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>

+ 6 - 5
user/user-service/src/main/resources/application-dev.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -15,8 +20,4 @@ spring:
   datasource:
     url: jdbc:mysql://127.0.0.1/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://127.0.0.1:6060/eureka/
+    password: Dev@123456

+ 6 - 5
user/user-service/src/main/resources/application-test.yml

@@ -6,6 +6,11 @@ spring:
   cloud:
     discovery:
       enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: E4B2M7W8Dx
   data:
     redis:
       database: 0
@@ -15,8 +20,4 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.209:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
-eureka:
-  client:
-    service-url:
-      defaultZone: http://192.168.0.210:6060/eureka/
+    password: Test@123456

+ 0 - 6
user/user-service/src/main/resources/application.yml

@@ -38,12 +38,6 @@ mybatis:
     map-underscore-to-camel-case: true
   mapper-locations: classpath*:mapper/**/**.xml
   type-aliases-package: cn.reghao.tnb.user.app.model.po
-eureka:
-  instance:
-    prefer-ip-address: true
-  client:
-    register-with-eureka: true
-    fetch-registry: true
 management:
   endpoints:
     web: