Ver código fonte

1.springboot 版本升级到 2.6.15
2.springcloud 版本升级到 2021.0.9
3.dubbo 版本升级到 3.3.0
4.springcloud 使用新建的 eureka 服务做服务注册和发现, 不再使用 spring-cloud-starter-zookeeper-discovery, 避免引入的 zookeeper client 版本和 dubbo 的发生冲突

reghao 1 ano atrás
pai
commit
3075d4c7cf
57 arquivos alterados com 650 adições e 290 exclusões
  1. 1 0
      README.md
  2. 5 33
      account/account-service/pom.xml
  3. 10 4
      account/account-service/src/main/resources/application-dev.yml
  4. 9 3
      account/account-service/src/main/resources/application-test.yml
  5. 3 0
      account/account-service/src/main/resources/application.yml
  6. 1 3
      account/account-service/src/test/java/UserAccountTest.java
  7. 4 4
      common/src/main/java/cn/reghao/tnb/common/exception/FilterExceptionHandler.java
  8. 12 15
      content/content-service/pom.xml
  9. 43 0
      content/content-service/src/main/java/cn/reghao/tnb/content/app/config/BeansConfig.java
  10. 10 4
      content/content-service/src/main/resources/application-dev.yml
  11. 9 3
      content/content-service/src/main/resources/application-test.yml
  12. 1 3
      content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/GeoTest.java
  13. 1 3
      content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/RcmdTest.java
  14. 1 3
      content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/SearchTest.java
  15. 3 5
      content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/VideoPostTest.java
  16. 5 18
      data/data-service/pom.xml
  17. 37 0
      data/data-service/src/main/java/cn/reghao/tnb/data/app/model/GatewayLog.java
  18. 2 2
      data/data-service/src/main/java/cn/reghao/tnb/data/app/repository/GatewayLogRepository.java
  19. 1 1
      data/data-service/src/main/java/cn/reghao/tnb/data/app/security/ResourceServerConfig.java
  20. 4 2
      data/data-service/src/main/java/cn/reghao/tnb/data/app/security/TokenTransferFilter.java
  21. 22 0
      data/data-service/src/main/java/cn/reghao/tnb/data/app/service/GatewayLogService.java
  22. 18 4
      data/data-service/src/main/resources/application-dev.yml
  23. 9 3
      data/data-service/src/main/resources/application-test.yml
  24. 1 3
      data/data-service/src/test/java/DataTest.java
  25. 21 0
      eureka/eureka-api/pom.xml
  26. 18 0
      eureka/eureka-api/src/main/java/cn/reghao/tnb/eureka/api/dto/EurekaInstance.java
  27. 13 0
      eureka/eureka-api/src/main/java/cn/reghao/tnb/eureka/api/iface/EurekaService.java
  28. 82 0
      eureka/eureka-server/pom.xml
  29. 17 0
      eureka/eureka-server/src/main/java/cn/reghao/tnb/eureka/server/EurekaServer.java
  30. 38 0
      eureka/eureka-server/src/main/java/cn/reghao/tnb/eureka/server/rpc/EurekaServiceImpl.java
  31. 3 0
      eureka/eureka-server/src/main/resources/application-dev.yml
  32. 3 0
      eureka/eureka-server/src/main/resources/application-test.yml
  33. 24 0
      eureka/eureka-server/src/main/resources/application.yml
  34. 68 0
      eureka/eureka-server/src/main/resources/logback-spring.xml
  35. 24 0
      eureka/pom.xml
  36. 3 31
      file/file-service/pom.xml
  37. 10 4
      file/file-service/src/main/resources/application-dev.yml
  38. 9 3
      file/file-service/src/main/resources/application-test.yml
  39. 3 0
      file/file-service/src/main/resources/application.yml
  40. 1 3
      file/file-service/src/test/java/FileTest.java
  41. 4 20
      gateway/pom.xml
  42. 2 2
      gateway/src/main/java/cn/reghao/tnb/gateway/lb/UserBalancerClientConfiguration.java
  43. 4 2
      gateway/src/main/java/cn/reghao/tnb/gateway/lb/UserReactiveLoadBalancerClientFilter.java
  44. 1 8
      gateway/src/main/java/cn/reghao/tnb/gateway/log/GatewayLogService.java
  45. 0 2
      gateway/src/main/java/cn/reghao/tnb/gateway/log/model/GatewayLog.java
  46. 9 11
      gateway/src/main/resources/application-dev.yml
  47. 8 2
      gateway/src/main/resources/application-test.yml
  48. 3 31
      message/message-service/pom.xml
  49. 10 4
      message/message-service/src/main/resources/application-dev.yml
  50. 9 3
      message/message-service/src/main/resources/application-test.yml
  51. 3 0
      message/message-service/src/main/resources/application.yml
  52. 22 3
      pom.xml
  53. 3 31
      user/user-service/pom.xml
  54. 10 6
      user/user-service/src/main/resources/application-dev.yml
  55. 9 5
      user/user-service/src/main/resources/application-test.yml
  56. 3 0
      user/user-service/src/main/resources/application.yml
  57. 1 3
      user/user-service/src/test/java/UserContactTest.java

+ 1 - 0
README.md

@@ -18,6 +18,7 @@
 
 ## 模块
 tnb 项目模块:
+- eureka:6060
 - gateway:6000
 - account:6001
 - user:6002

+ 5 - 33
account/account-service/pom.xml

@@ -110,47 +110,19 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.8</version>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
         </dependency>
-        <!--<dependency>
-            <groupId>org.apache.curator</groupId>
-            <artifactId>curator-recipes</artifactId>
-            <version>2.12.0</version>
-        </dependency>-->
 
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>
             <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.9.2</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.9.2</version>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
         </dependency>
 
         <dependency>

+ 10 - 4
account/account-service/src/main/resources/application-dev.yml

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 dubbo:
@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
   redis:
     database: 0
     host: localhost
@@ -25,4 +23,12 @@ spring:
   datasource:
     url: jdbc:mysql://localhost:3306/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
+    password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 9 - 3
account/account-service/src/main/resources/application-test.yml

@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
   redis:
     database: 0
     host: 192.168.0.210
@@ -25,4 +23,12 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.210:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
+    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/

+ 3 - 0
account/account-service/src/main/resources/application.yml

@@ -27,6 +27,9 @@ spring:
     name: account-service
   profiles:
     active: @profile.active@
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.zaxxer.hikari.HikariDataSource

+ 1 - 3
account/account-service/src/test/java/UserAccountTest.java

@@ -7,8 +7,7 @@ import cn.reghao.tnb.account.app.service.AccountRegistryService;
 import cn.reghao.tnb.account.app.service.OAuthAppService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.security.crypto.password.PasswordEncoder;
@@ -26,7 +25,6 @@ import java.util.List;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = AccountApplication.class)
-@RunWith(SpringRunner.class)
 public class UserAccountTest {
     @Autowired
     UserAccountMapper userAccountMapper;

+ 4 - 4
common/src/main/java/cn/reghao/tnb/common/exception/FilterExceptionHandler.java

@@ -21,7 +21,7 @@ import java.util.Map;
  * @author reghao
  * @date 2020-06-19 13:34:19
  */
-@RestController
+//@RestController
 public class FilterExceptionHandler extends BasicErrorController {
     public FilterExceptionHandler() {
         super(new DefaultErrorAttributes(), new ErrorProperties());
@@ -30,14 +30,14 @@ public class FilterExceptionHandler extends BasicErrorController {
     @Override
     @RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE})
     public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
-        Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
+        //Map<String, Object> body = getErrorAttributes(request, isIncludeStackTrace(request, MediaType.ALL));
         HttpStatus status = getStatus(request);
 
         Map<String,Object> map = new HashMap<>();
-        map.put("code",body.get("status"));
+        /*map.put("code",body.get("status"));
         map.put("msg",body.get("message"));
         map.put("timestamp", DateTimeConverter.format(System.currentTimeMillis()));
-        map.put("data",body.get("data"));
+        map.put("data",body.get("data"));*/
         return ResponseEntity.status(status).body(map);
     }
 }

+ 12 - 15
content/content-service/pom.xml

@@ -112,13 +112,7 @@
             <artifactId>spring-rabbit</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.8</version>
-        </dependency>
-
-        <dependency>
+        <!--<dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
             <exclusions>
@@ -131,18 +125,26 @@
         <dependency>
             <groupId>org.apache.zookeeper</groupId>
             <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
+            <version>3.7.2</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.slf4j</groupId>
                     <artifactId>slf4j-log4j12</artifactId>
                 </exclusion>
             </exclusions>
+        </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-zookeeper-config</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -157,13 +159,8 @@
 
         <dependency>
             <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.9.2</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.9.2</version>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
         </dependency>
 
         <dependency>

+ 43 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/config/BeansConfig.java

@@ -1,8 +1,18 @@
 package cn.reghao.tnb.content.app.config;
 
 import cn.reghao.jutil.jdk.string.IDObfuscation;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanPostProcessor;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
+import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
+import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
+
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author reghao
@@ -14,4 +24,37 @@ public class BeansConfig {
     public IDObfuscation userIdObfuscation() {
         return new IDObfuscation(0x12345);
     }
+
+    @Bean
+    public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
+        return new BeanPostProcessor() {
+
+            @Override
+            public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
+                if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
+                    customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
+                }
+                return bean;
+            }
+
+            private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
+                List<T> copy = mappings.stream()
+                        .filter(mapping -> mapping.getPatternParser() == null)
+                        .collect(Collectors.toList());
+                mappings.clear();
+                mappings.addAll(copy);
+            }
+
+            @SuppressWarnings("unchecked")
+            private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
+                try {
+                    Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
+                    field.setAccessible(true);
+                    return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
+                } catch (IllegalArgumentException | IllegalAccessException e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+        };
+    }
 }

+ 10 - 4
content/content-service/src/main/resources/application-dev.yml

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 dubbo:
@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
   data:
     mongodb:
       host: localhost
@@ -47,4 +45,12 @@ spring:
         driver-class-name: com.mysql.cj.jdbc.Driver
         jdbc-url: jdbc:mysql://localhost/tnb_content_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
         username: dev
-        password: Dev@123456
+        password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 9 - 3
content/content-service/src/main/resources/application-test.yml

@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
   data:
     mongodb:
       host: 192.168.0.210
@@ -47,4 +45,12 @@ spring:
         driver-class-name: com.mysql.cj.jdbc.Driver
         jdbc-url: jdbc:mysql://192.168.0.210/tnb_content_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
         username: test
-        password: Test@123456
+        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/

+ 1 - 3
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/GeoTest.java

@@ -17,8 +17,7 @@ import cn.reghao.tnb.content.app.geo.service.GeoService;
 import cn.reghao.tnb.content.app.geo.service.MapService;
 import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -38,7 +37,6 @@ import java.util.Map;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = ContentApplication.class)
-@RunWith(SpringRunner.class)
 public class GeoTest {
     @Autowired
     MapService mapService;

+ 1 - 3
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/RcmdTest.java

@@ -5,8 +5,7 @@ import cn.reghao.tnb.content.app.util.redis.ds.RedisHash;
 import cn.reghao.tnb.content.app.util.redis.ds.RedisList;
 import cn.reghao.tnb.content.app.util.redis.ds.RedisString;
 import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -21,7 +20,6 @@ import java.util.*;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = ContentApplication.class)
-@RunWith(SpringRunner.class)
 public class RcmdTest {
     @Autowired
     RecommendService recommendService;

+ 1 - 3
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/SearchTest.java

@@ -6,8 +6,7 @@ import cn.reghao.tnb.content.api.dto.VideoCard;
 import cn.reghao.tnb.content.app.ContentApplication;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -20,7 +19,6 @@ import org.springframework.test.context.junit4.SpringRunner;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = ContentApplication.class)
-@RunWith(SpringRunner.class)
 public class SearchTest {
     @DubboReference(check = false)
     DataSearchService dataSearchService;

+ 3 - 5
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/VideoPostTest.java

@@ -11,8 +11,7 @@ import cn.reghao.tnb.content.app.util.redis.ds.RedisSortedSet;
 import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
 import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
 import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -29,7 +28,6 @@ import java.util.stream.Collectors;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = ContentApplication.class)
-@RunWith(SpringRunner.class)
 public class VideoPostTest {
     @Autowired
     VideoPostMapper videoPostMapper;
@@ -92,7 +90,7 @@ public class VideoPostTest {
     UserInterestBased userInterestBased;
     @Test
     public void addTags() {
-        List<GroupCount> list = videoPostTagMapper.findByGroupBy();
+        /*List<GroupCount> list = videoPostTagMapper.findByGroupBy();
         List<String> list0 = list.stream().map(groupCount -> {
             String tagId = groupCount.getId();
             VideoTag videoTag = videoTagMapper.findByTagId(tagId);
@@ -107,7 +105,7 @@ public class VideoPostTest {
             videoTagMapper.deleteByTagId(tagId);
             videoPostTagMapper.deleteByTagId(tagId);
             log.info("delete tag id -> {}", tagId);
-        });
+        });*/
 
         /*Map<String, List<String>> map = new HashMap<>();
         List<VideoTag> list = videoTagMapper.findAll();

+ 5 - 18
data/data-service/pom.xml

@@ -47,6 +47,10 @@
             <artifactId>spring-boot-starter-amqp</artifactId>
             <version>2.0.3.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>io.projectreactor</groupId>
@@ -64,24 +68,7 @@
 
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>

+ 37 - 0
data/data-service/src/main/java/cn/reghao/tnb/data/app/model/GatewayLog.java

@@ -0,0 +1,37 @@
+package cn.reghao.tnb.data.app.model;
+
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.time.LocalDateTime;
+import java.util.Map;
+
+/**
+ * @author reghao
+ * @date 2024-11-20 16:40:24
+ */
+@Data
+@Document("GatewayLog")
+public class GatewayLog {
+    private String requestId;
+    private String targetRoute;
+    private String targetService;
+    private String requestUrl;
+    private String requestMethod;
+    private Map<String, String> requestHeaders;
+    private String requestBody;
+    private LocalDateTime requestTime;
+    private String remoteAddr;
+    private int remotePort;
+    private int statusCode;
+    private Map<String, String> responseHeaders;
+    private String responseBody;
+    private LocalDateTime responseTime;
+    // ms
+    private long executeTime;
+
+    public GatewayLog() {
+        this.remoteAddr = "";
+        this.remotePort = 0;
+    }
+}

+ 2 - 2
gateway/src/main/java/cn/reghao/tnb/gateway/log/repository/GatewayLogRepository.java → data/data-service/src/main/java/cn/reghao/tnb/data/app/repository/GatewayLogRepository.java

@@ -1,6 +1,6 @@
-package cn.reghao.tnb.gateway.log.repository;
+package cn.reghao.tnb.data.app.repository;
 
-import cn.reghao.tnb.gateway.log.model.GatewayLog;
+import cn.reghao.tnb.data.app.model.GatewayLog;
 import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
 import org.springframework.stereotype.Repository;
 

+ 1 - 1
data/data-service/src/main/java/cn/reghao/tnb/data/app/security/ResourceServerConfig.java

@@ -17,7 +17,7 @@ import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder;
 import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
 import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
 import org.springframework.security.oauth2.server.resource.authentication.ReactiveJwtAuthenticationConverterAdapter;
-import org.springframework.security.oauth2.server.resource.web.server.ServerBearerTokenAuthenticationConverter;
+import org.springframework.security.oauth2.server.resource.web.server.authentication.ServerBearerTokenAuthenticationConverter;
 import org.springframework.security.web.server.SecurityWebFilterChain;
 import reactor.core.publisher.Mono;
 

+ 4 - 2
data/data-service/src/main/java/cn/reghao/tnb/data/app/security/TokenTransferFilter.java

@@ -44,7 +44,7 @@ public class TokenTransferFilter implements WebFilter {
 
     @Override
     public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
-        return ReactiveSecurityContextHolder.getContext().switchIfEmpty(Mono.defer(() -> {
+        /*return ReactiveSecurityContextHolder.getContext().switchIfEmpty(Mono.defer(() -> {
             Authentication authentication = createAuthentication(exchange);
             SecurityContext securityContext = new SecurityContextImpl(authentication);
             log.debug("Populated SecurityContext with anonymous token: {}", authentication);
@@ -54,7 +54,9 @@ public class TokenTransferFilter implements WebFilter {
         })).flatMap((securityContext) -> {
             log.debug("SecurityContext contains anonymous token: {}", securityContext.getAuthentication());
             return chain.filter(exchange);
-        });
+        });*/
+
+        return chain.filter(exchange);
         /*return ReactiveSecurityContextHolder.getContext()
                 .map(securityContext -> {
                     return securityContext.getAuthentication();

+ 22 - 0
data/data-service/src/main/java/cn/reghao/tnb/data/app/service/GatewayLogService.java

@@ -0,0 +1,22 @@
+package cn.reghao.tnb.data.app.service;
+
+import cn.reghao.tnb.data.app.model.GatewayLog;
+import cn.reghao.tnb.data.app.repository.GatewayLogRepository;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author reghao
+ * @date 2024-11-20 16:41:21
+ */
+@Service
+public class GatewayLogService {
+    private final GatewayLogRepository gatewayLogRepository;
+
+    public GatewayLogService(GatewayLogRepository gatewayLogRepository) {
+        this.gatewayLogRepository = gatewayLogRepository;
+    }
+
+    public void saveGatewayLog(GatewayLog gatewayLog) {
+        gatewayLogRepository.insert(gatewayLog).subscribe();
+    }
+}

+ 18 - 4
data/data-service/src/main/resources/application-dev.yml

@@ -1,21 +1,35 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
   redis:
     host: 127.0.0.1
     port: 6379
     password: Dev@123456
     timeout: 5000
+  data:
+    mongodb:
+      host: 127.0.0.1
+      port: 27017
+      authentication-database: admin
+      username: dev
+      password: Dev@123456
+      database: "tnb_content_rdb"
   rabbitmq:
     host: localhost
     port: 5672
     virtual-host: /
     username: dev
-    password: Dev@123456
+    password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 9 - 3
data/data-service/src/main/resources/application-test.yml

@@ -6,8 +6,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
   redis:
     database: 0
     host: 192.168.0.210
@@ -19,4 +17,12 @@ spring:
     port: 5672
     virtual-host: /
     username: test
-    password: Test@123456
+    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/

+ 1 - 3
data/data-service/src/test/java/DataTest.java

@@ -1,7 +1,6 @@
 
 import cn.reghao.tnb.data.app.DataApplication;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -17,7 +16,6 @@ import java.util.stream.Collectors;
  */
 @ActiveProfiles("dev")
 @SpringBootTest(classes = DataApplication.class)
-@RunWith(SpringRunner.class)
 public class DataTest {
     @Test
     public void test() {

+ 21 - 0
eureka/eureka-api/pom.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>eureka</artifactId>
+        <groupId>cn.reghao.tnb</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>cn.reghao.tnb.eureka</groupId>
+    <artifactId>eureka-api</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+</project>

+ 18 - 0
eureka/eureka-api/src/main/java/cn/reghao/tnb/eureka/api/dto/EurekaInstance.java

@@ -0,0 +1,18 @@
+package cn.reghao.tnb.eureka.api.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * @author reghao
+ * @date 2025-04-24 15:11:49
+ */
+@Setter
+@Getter
+public class EurekaInstance implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private String name;
+}

+ 13 - 0
eureka/eureka-api/src/main/java/cn/reghao/tnb/eureka/api/iface/EurekaService.java

@@ -0,0 +1,13 @@
+package cn.reghao.tnb.eureka.api.iface;
+
+import cn.reghao.tnb.eureka.api.dto.EurekaInstance;
+
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2025-04-24 15:11:33
+ */
+public interface EurekaService {
+    List<EurekaInstance> getRegistryServices();
+}

+ 82 - 0
eureka/eureka-server/pom.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>eureka</artifactId>
+        <groupId>cn.reghao.tnb</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>cn.reghao.tnb.eureka</groupId>
+    <artifactId>eureka-server</artifactId>
+
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>cn.reghao.tnb.eureka</groupId>
+            <artifactId>eureka-api</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <properties>
+                <profile.active>dev</profile.active>
+            </properties>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+        </profile>
+        <profile>
+            <id>test</id>
+            <properties>
+                <profile.active>test</profile.active>
+            </properties>
+        </profile>
+    </profiles>
+
+    <build>
+        <finalName>tnb-eureka</finalName>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>application.yml</include>
+                    <include>application-${profile.active}.yml</include>
+                    <include>logback-spring.xml</include>
+                    <include>mapper/**</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <executable>true</executable>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 17 - 0
eureka/eureka-server/src/main/java/cn/reghao/tnb/eureka/server/EurekaServer.java

@@ -0,0 +1,17 @@
+package cn.reghao.tnb.eureka.server;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
+
+/**
+ * @author reghao
+ * @date 2021-11-01 18:59:39
+ */
+@SpringBootApplication
+@EnableEurekaServer
+public class EurekaServer {
+    public static void main(String[] args) {
+        SpringApplication.run(EurekaServer.class, args);
+    }
+}

+ 38 - 0
eureka/eureka-server/src/main/java/cn/reghao/tnb/eureka/server/rpc/EurekaServiceImpl.java

@@ -0,0 +1,38 @@
+package cn.reghao.tnb.eureka.server.rpc;
+
+import cn.reghao.tnb.eureka.api.dto.EurekaInstance;
+import cn.reghao.tnb.eureka.api.iface.EurekaService;
+import com.netflix.appinfo.InstanceInfo;
+import com.netflix.discovery.shared.Application;
+import com.netflix.eureka.EurekaServerContext;
+import com.netflix.eureka.EurekaServerContextHolder;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2025-04-24 15:10:40
+ */
+@DubboService
+@Service
+public class EurekaServiceImpl implements EurekaService {
+    @Override
+    public List<EurekaInstance> getRegistryServices() {
+        EurekaServerContext context = EurekaServerContextHolder.getInstance().getServerContext();
+        List<Application> applications = context.getRegistry().getSortedApplications();
+
+        List<EurekaInstance> list = new ArrayList<>();
+        for (Application application : applications) {
+            String name = application.getName();
+            List<InstanceInfo> instanceInfos = application.getInstances();
+            EurekaInstance eurekaInstance = new EurekaInstance();
+            eurekaInstance.setName(name);
+            list.add(eurekaInstance);
+        }
+
+        return list;
+    }
+}

+ 3 - 0
eureka/eureka-server/src/main/resources/application-dev.yml

@@ -0,0 +1,3 @@
+dubbo:
+  registry:
+    address: zookeeper://localhost:2181

+ 3 - 0
eureka/eureka-server/src/main/resources/application-test.yml

@@ -0,0 +1,3 @@
+dubbo:
+  registry:
+    address: zookeeper://192.168.0.210:2181

+ 24 - 0
eureka/eureka-server/src/main/resources/application.yml

@@ -0,0 +1,24 @@
+dubbo:
+  scan:
+    base-packages: cn.reghao.tnb.eureka.server.rpc
+  protocol:
+    name: dubbo
+    port: 16060
+server:
+  port: 6060
+spring:
+  application:
+    name: eureka-server
+  profiles:
+    active: dev
+eureka:
+  instance:
+    prefer-ip-address: true
+    #hostname: localhost
+  client:
+    register-with-eureka: false
+    fetch-registry: false
+    service-url:
+      defaultZone: http://localhost:${server.port}/eureka
+  server:
+    enable-self-preservation: false

+ 68 - 0
eureka/eureka-server/src/main/resources/logback-spring.xml

@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<configuration>
+    <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
+        <layout class="ch.qos.logback.classic.PatternLayout">
+            <pattern>
+                %d{HH:mm:ss.SSS} [%thread] %-5level %c %M %L - %msg%n
+            </pattern>
+        </layout>
+    </appender>
+
+    <!-- info 日志文件 -->
+    <appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>DENY</onMatch>
+            <onMismatch>ACCEPT</onMismatch>
+        </filter>
+        <encoder>
+            <pattern>
+                %d{HH:mm:ss.SSS} %-5level %c %M %L - %msg%n
+            </pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <!-- 滚动策略 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>
+                logs/info.%d.log
+            </fileNamePattern>
+        </rollingPolicy>
+    </appender>
+
+    <!-- error 日志文件 -->
+    <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>ERROR</level>
+        </filter>
+        <encoder>
+            <pattern>
+                %d{HH:mm:ss.SSS} %-5level %c %M %L - %msg%n
+            </pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>
+                logs/error.%d.log
+            </fileNamePattern>
+        </rollingPolicy>
+    </appender>
+
+    <springProfile name="dev">
+        <root level="info">
+            <appender-ref ref="consoleLog"></appender-ref>
+        </root>
+    </springProfile>
+    <springProfile name="test">
+        <root level="info">
+            <appender-ref ref="fileInfoLog"></appender-ref>
+            <appender-ref ref="fileErrorLog"></appender-ref>
+        </root>
+    </springProfile>
+    <springProfile name="prod">
+        <root level="info">
+            <appender-ref ref="fileInfoLog"></appender-ref>
+            <appender-ref ref="fileErrorLog"></appender-ref>
+        </root>
+    </springProfile>
+</configuration>

+ 24 - 0
eureka/pom.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>tnb</artifactId>
+        <groupId>cn.reghao.tnb</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>eureka</artifactId>
+    <packaging>pom</packaging>
+    <modules>
+        <module>eureka-api</module>
+        <module>eureka-server</module>
+    </modules>
+
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+</project>

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

@@ -120,32 +120,9 @@
             <version>1.1.4</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.8</version>
-        </dependency>
-
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>
@@ -161,13 +138,8 @@
 
         <dependency>
             <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.9.2</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.9.2</version>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
         </dependency>
     </dependencies>
 

+ 10 - 4
file/file-service/src/main/resources/application-dev.yml

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 dubbo:
@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
   redis:
     database: 0
     host: localhost
@@ -19,4 +17,12 @@ spring:
   datasource:
     url: jdbc:mysql://localhost:3306/tnb_content_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
+    password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 9 - 3
file/file-service/src/main/resources/application-test.yml

@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
   redis:
     database: 0
     host: 192.168.0.210
@@ -19,4 +17,12 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.210:3306/tnb_content_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
+    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/

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

@@ -19,6 +19,9 @@ spring:
     name: file-service
   profiles:
     active: @profile.active@
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.zaxxer.hikari.HikariDataSource

+ 1 - 3
file/file-service/src/test/java/FileTest.java

@@ -2,8 +2,7 @@ import cn.reghao.tnb.file.app.FileApplication;
 import cn.reghao.tnb.file.app.db.mapper.StoreConfigMapper;
 import cn.reghao.tnb.file.app.model.po.StoreConfig;
 import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -18,7 +17,6 @@ import java.util.List;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = FileApplication.class)
-@RunWith(SpringRunner.class)
 public class FileTest {
     @Autowired
     StoreConfigMapper storeConfigMapper;

+ 4 - 20
gateway/pom.xml

@@ -38,24 +38,7 @@
 
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>
@@ -80,8 +63,9 @@
         </dependency>
 
         <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.5</version>
         </dependency>
     </dependencies>
 

+ 2 - 2
gateway/src/main/java/cn/reghao/tnb/gateway/lb/UserBalancerClientConfiguration.java

@@ -4,8 +4,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties;
 import org.springframework.cloud.gateway.config.GatewayReactiveLoadBalancerClientAutoConfiguration;
-import org.springframework.cloud.gateway.config.LoadBalancerProperties;
 import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -15,7 +15,7 @@ import org.springframework.context.annotation.Configuration;
  * @date 2023-02-03 16:25:37
  */
 @Configuration
-@EnableConfigurationProperties(LoadBalancerProperties.class)
+//@EnableConfigurationProperties(LoadBalancerProperties.class)
 @AutoConfigureBefore(GatewayReactiveLoadBalancerClientAutoConfiguration.class)
 @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
 public class UserBalancerClientConfiguration {

+ 4 - 2
gateway/src/main/java/cn/reghao/tnb/gateway/lb/UserReactiveLoadBalancerClientFilter.java

@@ -3,9 +3,9 @@ package cn.reghao.tnb.gateway.lb;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.cloud.client.ServiceInstance;
 import org.springframework.cloud.client.loadbalancer.DefaultResponse;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties;
 import org.springframework.cloud.client.loadbalancer.LoadBalancerUriTools;
 import org.springframework.cloud.client.loadbalancer.Response;
-import org.springframework.cloud.gateway.config.LoadBalancerProperties;
 import org.springframework.cloud.gateway.filter.GatewayFilterChain;
 import org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter;
 import org.springframework.cloud.gateway.support.DelegatingServiceInstance;
@@ -57,7 +57,9 @@ public class UserReactiveLoadBalancerClientFilter extends ReactiveLoadBalancerCl
         try {
             return choose(exchange).doOnNext(response -> {
                 if (!response.hasServer()) {
-                    throw NotFoundException.create(this.properties.isUse404(), "Unable to find instance for " + url.getHost());
+                    //boolean notFound1 = this.properties.isUse404();
+                    boolean notFound = true;
+                    throw NotFoundException.create(notFound, "Unable to find instance for " + url.getHost());
                 }
 
                 URI uri = exchange.getRequest().getURI();

+ 1 - 8
gateway/src/main/java/cn/reghao/tnb/gateway/log/GatewayLogService.java

@@ -2,7 +2,6 @@ package cn.reghao.tnb.gateway.log;
 
 import cn.reghao.jutil.jdk.converter.DateTimeConverter;
 import cn.reghao.tnb.gateway.log.model.GatewayLog;
-import cn.reghao.tnb.gateway.log.repository.GatewayLogRepository;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.cloud.gateway.route.Route;
 import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
@@ -29,14 +28,8 @@ import java.util.Objects;
  */
 @Service
 public class GatewayLogService {
-    private final GatewayLogRepository gatewayLogRepository;
-
-    public GatewayLogService(GatewayLogRepository gatewayLogRepository) {
-        this.gatewayLogRepository = gatewayLogRepository;
-    }
-
     public void saveGatewayLog(GatewayLog gatewayLog) {
-        gatewayLogRepository.insert(gatewayLog).subscribe();
+        //gatewayLogRepository.insert(gatewayLog).subscribe();
     }
 
     public void setGatewayLog(ServerWebExchange exchange) {

+ 0 - 2
gateway/src/main/java/cn/reghao/tnb/gateway/log/model/GatewayLog.java

@@ -1,7 +1,6 @@
 package cn.reghao.tnb.gateway.log.model;
 
 import lombok.Data;
-import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.time.LocalDateTime;
 import java.util.Date;
@@ -12,7 +11,6 @@ import java.util.Map;
  * @date 2024-11-20 16:40:24
  */
 @Data
-@Document("GatewayLog")
 public class GatewayLog {
     private String requestId;
     private String targetRoute;

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

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 spring:
@@ -8,16 +8,14 @@ spring:
     host: localhost
     port: 6379
     password: Dev@123456
-  data:
-    mongodb:
-      host: 127.0.0.1
-      port: 27017
-      authentication-database: admin
-      username: dev
-      password: Dev@123456
-      database: "tnb_content_rdb"
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 8 - 2
gateway/src/main/resources/application-test.yml

@@ -19,5 +19,11 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://192.168.0.210:6060/eureka/

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

@@ -85,32 +85,9 @@
             <artifactId>spring-rabbit</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.8</version>
-        </dependency>
-
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>
@@ -132,13 +109,8 @@
 
         <dependency>
             <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.9.2</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.9.2</version>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
         </dependency>
     </dependencies>
 

+ 10 - 4
message/message-service/src/main/resources/application-dev.yml

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 dubbo:
@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: localhost:2181
   rabbitmq:
     host: localhost
     port: 5672
@@ -20,4 +18,12 @@ spring:
   datasource:
     url: jdbc:mysql://localhost:3306/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
+    password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

+ 9 - 3
message/message-service/src/main/resources/application-test.yml

@@ -9,8 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      connect-string: 192.168.0.210:2181
   rabbitmq:
     host: 192.168.0.210
     port: 5672
@@ -20,4 +18,12 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.210:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
+    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/

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

@@ -13,6 +13,9 @@ spring:
     name: message-service
   profiles:
     active: @profile.active@
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
 mybatis:
   configuration:
     map-underscore-to-camel-case: true

+ 22 - 3
pom.xml

@@ -18,6 +18,7 @@
         <module>file</module>
         <module>user</module>
         <module>data</module>
+        <module>eureka</module>
     </modules>
 
     <properties>
@@ -25,14 +26,14 @@
         <maven.compiler.target>11</maven.compiler.target>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-        <springboot.version>2.3.9.RELEASE</springboot.version>
-        <spring-cloud.version>Hoxton.SR10</spring-cloud.version>
+        <springboot.version>2.6.15</springboot.version>
+        <spring-cloud.version>2021.0.9</spring-cloud.version>
     </properties>
 
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.9.RELEASE</version>
+        <version>2.6.15</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
 
@@ -45,6 +46,13 @@
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-dependencies-bom</artifactId>
+                <version>3.3.0</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -86,6 +94,17 @@
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-spring-boot-starter</artifactId>
+            <version>3.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-zookeeper-spring-boot-starter</artifactId>
+            <version>3.3.0</version>
+        </dependency>
     </dependencies>
 
     <distributionManagement>

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

@@ -89,43 +89,15 @@
             <version>2.1.1</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-spring-boot-starter</artifactId>
-            <version>2.7.8</version>
-        </dependency>
-
         <dependency>
             <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-            <version>3.4.8</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
         </dependency>
 
         <dependency>
             <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.9.2</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.9.2</version>
+            <artifactId>springfox-boot-starter</artifactId>
+            <version>3.0.0</version>
         </dependency>
     </dependencies>
 

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

@@ -1,5 +1,5 @@
 log:
-  enabled: true
+  enabled: false
   ws-url: ws://bnt.reghao.cn/ws/log/push
   token: 012345678
 dubbo:
@@ -9,10 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      discovery:
-        prefer-ip-address: true
-      connect-string: localhost:2181
   redis:
     database: 0
     host: localhost
@@ -21,4 +17,12 @@ spring:
   datasource:
     url: jdbc:mysql://localhost:3306/tnb_account_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
-    password: Dev@123456
+    password: Dev@123456
+eureka:
+  instance:
+    prefer-ip-address: true
+  client:
+    register-with-eureka: true
+    fetch-registry: true
+    service-url:
+      defaultZone: http://localhost:6060/eureka/

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

@@ -9,10 +9,6 @@ spring:
   cloud:
     discovery:
       enabled: true
-    zookeeper:
-      discovery:
-        prefer-ip-address: true
-      connect-string: 192.168.0.210:2181
   redis:
     database: 0
     host: 192.168.0.210
@@ -21,4 +17,12 @@ spring:
   datasource:
     url: jdbc:mysql://192.168.0.210:3306/tnb_account_tdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: test
-    password: Test@123456
+    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/

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

@@ -15,6 +15,9 @@ spring:
     name: user-service
   profiles:
     active: @profile.active@
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
   datasource:
     driver-class-name: com.mysql.cj.jdbc.Driver
     type: com.zaxxer.hikari.HikariDataSource

+ 1 - 3
user/user-service/src/test/java/UserContactTest.java

@@ -2,8 +2,7 @@ import cn.reghao.tnb.user.app.UserApplication;
 import cn.reghao.tnb.user.app.db.mapper.UserContactMapper;
 import cn.reghao.tnb.user.app.model.po.UserContact;
 import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -18,7 +17,6 @@ import java.util.List;
 @Slf4j
 @ActiveProfiles("dev")
 @SpringBootTest(classes = UserApplication.class)
-@RunWith(SpringRunner.class)
 public class UserContactTest {
     @Autowired
     UserContactMapper userContactMapper;