Selaa lähdekoodia

gateway, auth, user 使用 nacos 配置中心获取配置

reghao 3 viikkoa sitten
vanhempi
commit
19254619c2

+ 5 - 1
auth/auth-service/pom.xml

@@ -95,6 +95,10 @@
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -152,7 +156,7 @@
                 <filtering>true</filtering>
                 <includes>
                     <include>application.yml</include>
-                    <include>application-${profile.active}.yml</include>
+                    <!--<include>application-${profile.active}.yml</include>-->
                     <include>mapper/**</include>
                     <include>*.xml</include>
                     <include>static/**</include>

+ 92 - 0
auth/auth-service/src/main/resources/application-dev-full.yml

@@ -0,0 +1,92 @@
+dubbo:
+  application:
+    name: ${spring.application.name}
+    qos-enable: true
+    qos-port: 16101
+    qos-accept-foreign-ip: false
+  scan:
+    base-packages: cn.reghao.tnb.auth.app.rpc
+  protocol:
+    name: dubbo
+    port: 6101
+  registry:
+    group: dubbo
+    address: zookeeper://127.0.0.1:2181
+server:
+  port: 6001
+  tomcat:
+    max-http-form-post-size: 4MB
+  servlet:
+    session:
+      cookie:
+        secure: true
+        http-only: true
+        # org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getSessionTimeoutInMinutes 获取超时时间
+        # 两个请求间隔的最大时间, 超过此时间则会话过期
+      timeout: 10m
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: auth-service
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
+  servlet:
+    multipart:
+      max-request-size: 5MB
+      max-file-size: 5MB
+  session:
+    store-type: redis
+    redis:
+      namespace: tnb:auth:session
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.zaxxer.hikari.HikariDataSource
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 10
+      auto-commit: true
+      idle-timeout: 30000
+      pool-name: EvaluationHikariCP
+      max-lifetime: 1800000
+      connection-timeout: 30000
+      connection-test-query: SELECT 1
+    url: jdbc:mysql://127.0.0.1/tnb_account_rdb?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
+    username: test
+    password: Test_123456
+  freemarker:
+    template-loader-path:
+      - classpath:/templates
+    cache: false
+    check-template-location: true
+    request-context-attribute: request
+    charset: utf-8
+    suffix: .ftl
+    settings:
+      classic_compatible: true #处理空值
+      template_exception_handler: rethrow
+      template_update_delay: 0
+      datetime_format: yyyy-MM-dd HH:mm
+      number_format: 0.##
+  cloud:
+    discovery:
+      enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: Test_123456
+  data:
+    redis:
+      database: 0
+      host: 127.0.0.1
+      port: 6379
+      password: Test_123456
+  rabbitmq:
+    host: 127.0.0.1
+    port: 5672
+    virtual-host: /
+    username: test
+    password: Test_123456

+ 92 - 0
auth/auth-service/src/main/resources/application-test-full.yml

@@ -0,0 +1,92 @@
+dubbo:
+  application:
+    name: ${spring.application.name}
+    qos-enable: true
+    qos-port: 16101
+    qos-accept-foreign-ip: false
+  scan:
+    base-packages: cn.reghao.tnb.auth.app.rpc
+  protocol:
+    name: dubbo
+    port: 6101
+  registry:
+    group: dubbo
+    address: zookeeper://192.168.0.209:2181
+server:
+  port: 6001
+  tomcat:
+    max-http-form-post-size: 4MB
+  servlet:
+    session:
+      cookie:
+        secure: true
+        http-only: true
+        # org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getSessionTimeoutInMinutes 获取超时时间
+        # 两个请求间隔的最大时间, 超过此时间则会话过期
+      timeout: 10m
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: auth-service
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
+  servlet:
+    multipart:
+      max-request-size: 5MB
+      max-file-size: 5MB
+  session:
+    store-type: redis
+    redis:
+      namespace: tnb:auth:session
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.zaxxer.hikari.HikariDataSource
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 10
+      auto-commit: true
+      idle-timeout: 30000
+      pool-name: EvaluationHikariCP
+      max-lifetime: 1800000
+      connection-timeout: 30000
+      connection-test-query: SELECT 1
+    url: jdbc:mysql://192.168.0.209/tnb_account_tdb?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
+    username: test
+    password: Test_123456
+  freemarker:
+    template-loader-path:
+      - classpath:/templates
+    cache: false
+    check-template-location: true
+    request-context-attribute: request
+    charset: utf-8
+    suffix: .ftl
+    settings:
+      classic_compatible: true #处理空值
+      template_exception_handler: rethrow
+      template_update_delay: 0
+      datetime_format: yyyy-MM-dd HH:mm
+      number_format: 0.##
+  cloud:
+    discovery:
+      enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: Test_123456
+  data:
+    redis:
+      database: 0
+      host: 192.168.0.209
+      port: 6379
+      password: Test_123456
+  rabbitmq:
+    host: 192.168.0.209
+    port: 5672
+    virtual-host: /
+    username: test
+    password: Test_123456

+ 14 - 63
auth/auth-service/src/main/resources/application.yml

@@ -1,68 +1,19 @@
-dubbo:
-  application:
-    name: ${spring.application.name}
-    qos-enable: true
-    qos-port: 16101
-    qos-accept-foreign-ip: false
-  scan:
-    base-packages: cn.reghao.tnb.auth.app.rpc
-  protocol:
-    name: dubbo
-    port: 6101
-server:
-  port: 6001
-  tomcat:
-    max-http-form-post-size: 4MB
-  servlet:
-    session:
-      cookie:
-        secure: true
-        http-only: true
-        # org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getSessionTimeoutInMinutes 获取超时时间
-        # 两个请求间隔的最大时间, 超过此时间则会话过期
-      timeout: 10m
 spring:
-  threads:
-    virtual:
-      enabled: true
   application:
     name: auth-service
   profiles:
     active: @profile.active@
-  mvc:
-    pathmatch:
-      matching-strategy: ant_path_matcher
-  servlet:
-    multipart:
-      max-request-size: 5MB
-      max-file-size: 5MB
-  session:
-    store-type: redis
-    redis:
-      namespace: tnb:auth:session
-  datasource:
-    driver-class-name: com.mysql.cj.jdbc.Driver
-    type: com.zaxxer.hikari.HikariDataSource
-    hikari:
-      minimum-idle: 5
-      maximum-pool-size: 10
-      auto-commit: true
-      idle-timeout: 30000
-      pool-name: EvaluationHikariCP
-      max-lifetime: 1800000
-      connection-timeout: 30000
-      connection-test-query: SELECT 1
-  freemarker:
-    template-loader-path:
-      - classpath:/templates
-    cache: false
-    check-template-location: true
-    request-context-attribute: request
-    charset: utf-8
-    suffix: .ftl
-    settings:
-      classic_compatible: true #处理空值
-      template_exception_handler: rethrow
-      template_update_delay: 0
-      datetime_format: yyyy-MM-dd HH:mm
-      number_format: 0.##
+  threads:
+    virtual:
+      enabled: true
+  cloud:
+    nacos:
+      config:
+        server-addr: 127.0.0.1
+        group: DEFAULT_GROUP
+        file-extension: yaml
+        username: nacos
+        password: Test_123456
+  config:
+    import:
+      - nacos:${spring.application.name}-${spring.profiles.active}

+ 68 - 0
auth/auth-service/src/main/resources/application0.yml

@@ -0,0 +1,68 @@
+dubbo:
+  application:
+    name: ${spring.application.name}
+    qos-enable: true
+    qos-port: 16101
+    qos-accept-foreign-ip: false
+  scan:
+    base-packages: cn.reghao.tnb.auth.app.rpc
+  protocol:
+    name: dubbo
+    port: 6101
+server:
+  port: 6001
+  tomcat:
+    max-http-form-post-size: 4MB
+  servlet:
+    session:
+      cookie:
+        secure: true
+        http-only: true
+        # org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getSessionTimeoutInMinutes 获取超时时间
+        # 两个请求间隔的最大时间, 超过此时间则会话过期
+      timeout: 10m
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: auth-service
+  profiles:
+    active: @profile.active@
+  mvc:
+    pathmatch:
+      matching-strategy: ant_path_matcher
+  servlet:
+    multipart:
+      max-request-size: 5MB
+      max-file-size: 5MB
+  session:
+    store-type: redis
+    redis:
+      namespace: tnb:auth:session
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    type: com.zaxxer.hikari.HikariDataSource
+    hikari:
+      minimum-idle: 5
+      maximum-pool-size: 10
+      auto-commit: true
+      idle-timeout: 30000
+      pool-name: EvaluationHikariCP
+      max-lifetime: 1800000
+      connection-timeout: 30000
+      connection-test-query: SELECT 1
+  freemarker:
+    template-loader-path:
+      - classpath:/templates
+    cache: false
+    check-template-location: true
+    request-context-attribute: request
+    charset: utf-8
+    suffix: .ftl
+    settings:
+      classic_compatible: true #处理空值
+      template_exception_handler: rethrow
+      template_update_delay: 0
+      datetime_format: yyyy-MM-dd HH:mm
+      number_format: 0.##

+ 5 - 3
gateway/pom.xml

@@ -60,6 +60,10 @@
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>commons-lang</groupId>
@@ -104,10 +108,8 @@
                 <directory>src/main/resources</directory>
                 <filtering>true</filtering>
                 <includes>
-                    <!--<include>bootstrap.properties</include>
-                    <include>application.properties</include>-->
                     <include>application.yml</include>
-                    <include>application-${profile.active}.yml</include>
+                    <!--<include>application-${profile.active}.yml</include>-->
                     <include>*.xml</include>
                 </includes>
             </resource>

+ 246 - 0
gateway/src/main/resources/application-dev-full.yml

@@ -0,0 +1,246 @@
+server:
+  port: 6000
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: gateway
+  cloud:
+    discovery:
+      enabled: true
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        username: nacos
+        password: Test_123456
+    loadbalancer:
+      ribbon:
+        enabled: false
+    gateway:
+      # 默认过滤器(对所有 route 均生效)
+      default-filters:
+        # 限流配置
+        - name: MyRequestRateLimiter
+          args:
+            # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
+            deny-empty-key: false
+            # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
+            key-resolver: "#{@keyResolver}"
+            #            rate-limiter: "#{@myRateLimiter}"
+            #            my-rate-limiter.requestedTokens: 1
+            rate-limiter: "#{@redisRateLimiter}"
+            # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
+            redis-rate-limiter.replenishRate: 100
+            # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
+            redis-rate-limiter.burstCapacity: 150
+            # 单次请求消费的 token 数量
+            redis-rate-limiter.requestedTokens: 1
+      routes:
+        - id: account-router
+          # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/account/**
+          filters:
+            - StripPrefix=0
+        - id: static-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/dist/images/**
+          filters:
+            - StripPrefix=0
+        - id: auth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/auth/**
+          filters:
+            - StripPrefix=0
+        - id: oauth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/oauth/**
+          filters:
+            - StripPrefix=0
+        - id: account-admin-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/admin/account/**
+          filters:
+            - StripPrefix=0
+        - id: account-open-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/open/account/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: user-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/user/**
+          filters:
+            - StripPrefix=0
+        - id: user-admin-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/admin/user/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: content-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-admin-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/admin/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-open-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/open/content/**
+          filters:
+            - StripPrefix=0
+        - id: timeline-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/timeline/**
+          filters:
+            - StripPrefix=0
+        - id: search-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/search/**
+          filters:
+            - StripPrefix=0
+        - id: mall-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/mall/**
+          filters:
+            - StripPrefix=0
+        - id: geo-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/geo/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: data-router
+          uri: lb://data-service
+          #uri: http://192.168.0.39:6005
+          predicates:
+            - Path=/api/data/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: file-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/file/**
+          filters:
+            - StripPrefix=0
+        - id: file1-router
+          uri: lb://file-service
+          predicates:
+            - Path=/file/**
+          filters:
+            - StripPrefix=0
+        - id: disk-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/disk/**
+          filters:
+            - StripPrefix=0
+        - id: file-admin-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/admin/file/**
+          filters:
+            - StripPrefix=0
+        - id: file-open-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/open/file/**
+          filters:
+            - StripPrefix=0
+        - id: chat-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/chat/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: message-websocket
+          uri: lb:ws://message-service
+          predicates:
+            - Path=/ws/**
+        - id: message-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/message/**
+        - id: message-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/message/**
+        - id: tnb-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/tnb/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: log-websocket
+          uri: lb:ws://search-service
+          predicates:
+            - Path=/logws/**
+        - id: search1-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/search1/**
+        - id: blog-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/blog/**
+        - id: comment-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/comment/**
+          filters:
+            - StripPrefix=0
+        - id: admin-router
+          uri: lb://admin-service
+          predicates:
+            - Path=/api/admin1/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: oss-router
+          uri: http://127.0.0.1:8010
+          predicates:
+            - Path=/api/oss/**
+          filters:
+            - StripPrefix=0
+  rabbitmq:
+    host: 127.0.0.1
+    port: 5672
+    virtual-host: /
+    username: test
+    password: Test_123456
+  data:
+    redis:
+      database: 0
+      host: 127.0.0.1
+      port: 6379
+      password: Test_123456
+app:
+  resources:
+    _api_admin_: tnb_admin
+    _api_oss_: tnb_admin
+    _api_blog_bg_: tnb_admin
+    _api_disk_: tnb_disk

+ 246 - 0
gateway/src/main/resources/application-test-full.yml

@@ -0,0 +1,246 @@
+server:
+  port: 6000
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: gateway
+  cloud:
+    discovery:
+      enabled: true
+    nacos:
+      discovery:
+        server-addr: 192.168.0.209:8848
+        username: nacos
+        password: Test_123456
+    loadbalancer:
+      ribbon:
+        enabled: false
+    gateway:
+      # 默认过滤器(对所有 route 均生效)
+      default-filters:
+        # 限流配置
+        - name: MyRequestRateLimiter
+          args:
+            # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
+            deny-empty-key: false
+            # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
+            key-resolver: "#{@keyResolver}"
+            #            rate-limiter: "#{@myRateLimiter}"
+            #            my-rate-limiter.requestedTokens: 1
+            rate-limiter: "#{@redisRateLimiter}"
+            # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
+            redis-rate-limiter.replenishRate: 100
+            # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
+            redis-rate-limiter.burstCapacity: 150
+            # 单次请求消费的 token 数量
+            redis-rate-limiter.requestedTokens: 1
+      routes:
+        - id: account-router
+          # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/account/**
+          filters:
+            - StripPrefix=0
+        - id: static-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/dist/images/**
+          filters:
+            - StripPrefix=0
+        - id: auth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/auth/**
+          filters:
+            - StripPrefix=0
+        - id: oauth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/oauth/**
+          filters:
+            - StripPrefix=0
+        - id: account-admin-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/admin/account/**
+          filters:
+            - StripPrefix=0
+        - id: account-open-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/open/account/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: user-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/user/**
+          filters:
+            - StripPrefix=0
+        - id: user-admin-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/admin/user/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: content-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-admin-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/admin/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-open-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/open/content/**
+          filters:
+            - StripPrefix=0
+        - id: timeline-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/timeline/**
+          filters:
+            - StripPrefix=0
+        - id: search-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/search/**
+          filters:
+            - StripPrefix=0
+        - id: mall-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/mall/**
+          filters:
+            - StripPrefix=0
+        - id: geo-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/geo/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: data-router
+          uri: lb://data-service
+          #uri: http://192.168.0.39:6005
+          predicates:
+            - Path=/api/data/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: file-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/file/**
+          filters:
+            - StripPrefix=0
+        - id: file1-router
+          uri: lb://file-service
+          predicates:
+            - Path=/file/**
+          filters:
+            - StripPrefix=0
+        - id: disk-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/disk/**
+          filters:
+            - StripPrefix=0
+        - id: file-admin-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/admin/file/**
+          filters:
+            - StripPrefix=0
+        - id: file-open-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/open/file/**
+          filters:
+            - StripPrefix=0
+        - id: chat-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/chat/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: message-websocket
+          uri: lb:ws://message-service
+          predicates:
+            - Path=/ws/**
+        - id: message-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/message/**
+        - id: message-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/message/**
+        - id: tnb-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/tnb/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: log-websocket
+          uri: lb:ws://search-service
+          predicates:
+            - Path=/logws/**
+        - id: search1-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/search1/**
+        - id: blog-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/blog/**
+        - id: comment-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/comment/**
+          filters:
+            - StripPrefix=0
+        - id: admin-router
+          uri: lb://admin-service
+          predicates:
+            - Path=/api/admin1/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: oss-router
+          uri: http://127.0.0.1:8010
+          predicates:
+            - Path=/api/oss/**
+          filters:
+            - StripPrefix=0
+  rabbitmq:
+    host: 192.168.0.209
+    port: 5672
+    virtual-host: /
+    username: test
+    password: Test_123456
+  data:
+    redis:
+      database: 0
+      host: 192.168.0.209
+      port: 6379
+      password: Test_123456
+app:
+  resources:
+    _api_admin_: tnb_admin
+    _api_oss_: tnb_admin
+    _api_blog_bg_: tnb_admin
+    _api_disk_: tnb_disk

+ 13 - 230
gateway/src/main/resources/application.yml

@@ -1,236 +1,19 @@
-server:
-  port: 6000
 spring:
-  threads:
-    virtual:
-      enabled: true
   application:
     name: gateway
   profiles:
     active: @profile.active@
+  threads:
+    virtual:
+      enabled: true
   cloud:
-    loadbalancer:
-      ribbon:
-        enabled: false
-    gateway:
-      # 默认过滤器(对所有 route 均生效)
-      default-filters:
-        # 限流配置
-        - name: MyRequestRateLimiter
-          args:
-            # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
-            deny-empty-key: false
-            # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
-            key-resolver: "#{@keyResolver}"
-#            rate-limiter: "#{@myRateLimiter}"
-#            my-rate-limiter.requestedTokens: 1
-            rate-limiter: "#{@redisRateLimiter}"
-            # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
-            redis-rate-limiter.replenishRate: 100
-            # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
-            redis-rate-limiter.burstCapacity: 150
-            # 单次请求消费的 token 数量
-            redis-rate-limiter.requestedTokens: 1
-      routes:
-        - id: account-router
-          # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
-          uri: lb://auth-service
-          predicates:
-            - Path=/api/account/**
-          filters:
-            - StripPrefix=0
-        - id: static-router
-          uri: lb://auth-service
-          predicates:
-            - Path=/dist/images/**
-          filters:
-            - StripPrefix=0
-        - id: auth-router
-          uri: lb://auth-service
-          predicates:
-            - Path=/api/auth/**
-          filters:
-            - StripPrefix=0
-        - id: oauth-router
-          uri: lb://auth-service
-          predicates:
-            - Path=/oauth/**
-          filters:
-            - StripPrefix=0
-        - id: account-admin-router
-          uri: lb://auth-service
-          predicates:
-            - Path=/api/admin/account/**
-          filters:
-            - StripPrefix=0
-        - id: account-open-router
-          uri: lb://auth-service
-          predicates:
-            - Path=/api/open/account/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: user-router
-          uri: lb://user-service
-          predicates:
-            - Path=/api/user/**
-          filters:
-            - StripPrefix=0
-        - id: user-admin-router
-          uri: lb://user-service
-          predicates:
-            - Path=/api/admin/user/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: content-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/content/**
-          filters:
-            - StripPrefix=0
-        - id: content-admin-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/admin/content/**
-          filters:
-            - StripPrefix=0
-        - id: content-open-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/open/content/**
-          filters:
-            - StripPrefix=0
-        - id: timeline-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/timeline/**
-          filters:
-            - StripPrefix=0
-        - id: search-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/search/**
-          filters:
-            - StripPrefix=0
-        - id: mall-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/mall/**
-          filters:
-            - StripPrefix=0
-        - id: geo-router
-          uri: lb://content-service
-          predicates:
-            - Path=/api/geo/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: data-router
-          uri: lb://data-service
-          #uri: http://192.168.0.39:6005
-          predicates:
-            - Path=/api/data/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: file-router
-          uri: lb://file-service
-          predicates:
-            - Path=/api/file/**
-          filters:
-            - StripPrefix=0
-        - id: file1-router
-          uri: lb://file-service
-          predicates:
-            - Path=/file/**
-          filters:
-            - StripPrefix=0
-        - id: disk-router
-          uri: lb://file-service
-          predicates:
-            - Path=/api/disk/**
-          filters:
-            - StripPrefix=0
-        - id: file-admin-router
-          uri: lb://file-service
-          predicates:
-            - Path=/api/admin/file/**
-          filters:
-            - StripPrefix=0
-        - id: file-open-router
-          uri: lb://file-service
-          predicates:
-            - Path=/api/open/file/**
-          filters:
-            - StripPrefix=0
-        - id: chat-router
-          uri: lb://file-service
-          predicates:
-            - Path=/api/chat/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: message-websocket
-          uri: lb:ws://message-service
-          predicates:
-            - Path=/ws/**
-        - id: message-router
-          uri: lb://message-service
-          predicates:
-            - Path=/api/message/**
-        - id: message-admin-router
-          uri: lb://message-service
-          predicates:
-            - Path=/api/admin/message/**
-        - id: tnb-admin-router
-          uri: lb://message-service
-          predicates:
-            - Path=/api/admin/tnb/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: log-websocket
-          uri: lb:ws://search-service
-          predicates:
-            - Path=/logws/**
-        - id: search1-router
-          uri: lb://search-service
-          predicates:
-            - Path=/api/search1/**
-        - id: blog-router
-          uri: lb://search-service
-          predicates:
-            - Path=/api/blog/**
-        - id: comment-router
-          uri: lb://search-service
-          predicates:
-            - Path=/api/comment/**
-          filters:
-            - StripPrefix=0
-        - id: admin-router
-          uri: lb://admin-service
-          predicates:
-            - Path=/api/admin1/**
-          filters:
-            - StripPrefix=0
-        ###############################################################################
-        - id: oss-router
-          uri: http://127.0.0.1:8010
-          predicates:
-            - Path=/api/oss/**
-          filters:
-            - StripPrefix=0
-#    gateway:
-#      globalcors:
-#        cors-configurations:
-#          '[/**]':
-#            allowedOrigins: "*"
-#            allowedMethods: "*"
-#            allowedHeaders: "*"
-app:
-  resources:
-    _api_admin_: tnb_admin
-    _api_oss_: tnb_admin
-    _api_blog_bg_: tnb_admin
-    _api_disk_: tnb_disk
+    nacos:
+      config:
+        server-addr: 127.0.0.1
+        group: DEFAULT_GROUP
+        file-extension: yaml
+        username: nacos
+        password: Test_123456
+  config:
+    import:
+      - nacos:${spring.application.name}-${spring.profiles.active}

+ 236 - 0
gateway/src/main/resources/application0.yml

@@ -0,0 +1,236 @@
+server:
+  port: 6000
+spring:
+  threads:
+    virtual:
+      enabled: true
+  application:
+    name: gateway
+  profiles:
+    active: @profile.active@
+  cloud:
+    loadbalancer:
+      ribbon:
+        enabled: false
+    gateway:
+      # 默认过滤器(对所有 route 均生效)
+      default-filters:
+        # 限流配置
+        - name: MyRequestRateLimiter
+          args:
+            # 如果 keyResolver 返回空 key 则拒绝请求返回 403, 默认 true 表示拒绝, false 表示允许访问
+            deny-empty-key: false
+            # 自定义的 KeyResolver(从请求 exchange 解析 id 来区分独立的限流单元, id 可以是 userId, remoteAddr, sessionId 等)
+            key-resolver: "#{@keyResolver}"
+#            rate-limiter: "#{@myRateLimiter}"
+#            my-rate-limiter.requestedTokens: 1
+            rate-limiter: "#{@redisRateLimiter}"
+            # 令牌桶算法每秒补充的 token 数量(每秒的请求数量)
+            redis-rate-limiter.replenishRate: 100
+            # 令牌桶算法的 token 最大数量(每秒的最大请求数量)
+            redis-rate-limiter.burstCapacity: 150
+            # 单次请求消费的 token 数量
+            redis-rate-limiter.requestedTokens: 1
+      routes:
+        - id: account-router
+          # spring-cloud-starter-zookeeper-discovery 提供服务发现功能
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/account/**
+          filters:
+            - StripPrefix=0
+        - id: static-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/dist/images/**
+          filters:
+            - StripPrefix=0
+        - id: auth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/auth/**
+          filters:
+            - StripPrefix=0
+        - id: oauth-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/oauth/**
+          filters:
+            - StripPrefix=0
+        - id: account-admin-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/admin/account/**
+          filters:
+            - StripPrefix=0
+        - id: account-open-router
+          uri: lb://auth-service
+          predicates:
+            - Path=/api/open/account/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: user-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/user/**
+          filters:
+            - StripPrefix=0
+        - id: user-admin-router
+          uri: lb://user-service
+          predicates:
+            - Path=/api/admin/user/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: content-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-admin-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/admin/content/**
+          filters:
+            - StripPrefix=0
+        - id: content-open-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/open/content/**
+          filters:
+            - StripPrefix=0
+        - id: timeline-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/timeline/**
+          filters:
+            - StripPrefix=0
+        - id: search-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/search/**
+          filters:
+            - StripPrefix=0
+        - id: mall-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/mall/**
+          filters:
+            - StripPrefix=0
+        - id: geo-router
+          uri: lb://content-service
+          predicates:
+            - Path=/api/geo/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: data-router
+          uri: lb://data-service
+          #uri: http://192.168.0.39:6005
+          predicates:
+            - Path=/api/data/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: file-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/file/**
+          filters:
+            - StripPrefix=0
+        - id: file1-router
+          uri: lb://file-service
+          predicates:
+            - Path=/file/**
+          filters:
+            - StripPrefix=0
+        - id: disk-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/disk/**
+          filters:
+            - StripPrefix=0
+        - id: file-admin-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/admin/file/**
+          filters:
+            - StripPrefix=0
+        - id: file-open-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/open/file/**
+          filters:
+            - StripPrefix=0
+        - id: chat-router
+          uri: lb://file-service
+          predicates:
+            - Path=/api/chat/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: message-websocket
+          uri: lb:ws://message-service
+          predicates:
+            - Path=/ws/**
+        - id: message-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/message/**
+        - id: message-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/message/**
+        - id: tnb-admin-router
+          uri: lb://message-service
+          predicates:
+            - Path=/api/admin/tnb/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: log-websocket
+          uri: lb:ws://search-service
+          predicates:
+            - Path=/logws/**
+        - id: search1-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/search1/**
+        - id: blog-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/blog/**
+        - id: comment-router
+          uri: lb://search-service
+          predicates:
+            - Path=/api/comment/**
+          filters:
+            - StripPrefix=0
+        - id: admin-router
+          uri: lb://admin-service
+          predicates:
+            - Path=/api/admin1/**
+          filters:
+            - StripPrefix=0
+        ###############################################################################
+        - id: oss-router
+          uri: http://127.0.0.1:8010
+          predicates:
+            - Path=/api/oss/**
+          filters:
+            - StripPrefix=0
+#    gateway:
+#      globalcors:
+#        cors-configurations:
+#          '[/**]':
+#            allowedOrigins: "*"
+#            allowedMethods: "*"
+#            allowedHeaders: "*"
+app:
+  resources:
+    _api_admin_: tnb_admin
+    _api_oss_: tnb_admin
+    _api_blog_bg_: tnb_admin
+    _api_disk_: tnb_disk

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

@@ -78,10 +78,10 @@
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
-        <!--<dependency>
+        <dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
-        </dependency>-->
+        </dependency>
 
         <dependency>
             <groupId>org.springframework.cloud</groupId>
@@ -141,7 +141,7 @@
                 <filtering>true</filtering>
                 <includes>
                     <include>application.yml</include>
-                    <include>application-${profile.active}.yml</include>
+                    <!--<include>application-${profile.active}.yml</include>-->
                     <include>mapper/**</include>
                     <include>*.xml</include>
                 </includes>

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

@@ -57,7 +57,7 @@ mybatis:
 management:
   endpoints:
     web:
-      #      base-path: /api/user/actuator
+      base-path: /api/user/actuator
       exposure:
         include: "*"
   metrics:

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

@@ -57,7 +57,7 @@ mybatis:
 management:
   endpoints:
     web:
-      #      base-path: /api/user/actuator
+      base-path: /api/user/actuator
       exposure:
         include: "*"
   metrics:

+ 11 - 11
user/user-service/src/main/resources/application.yml

@@ -6,14 +6,14 @@ spring:
   threads:
     virtual:
       enabled: true
-#  cloud:
-#    nacos:
-#      config:
-#        server-addr: 127.0.0.1
-#        group: DEFAULT_GROUP
-#        file-extension: yaml
-#        username: nacos
-#        password: Test_123456
-#  config:
-#    import:
-#      - nacos:${spring.application.name}-${spring.profiles.active}
+  cloud:
+    nacos:
+      config:
+        server-addr: 127.0.0.1
+        group: DEFAULT_GROUP
+        file-extension: yaml
+        username: nacos
+        password: Test_123456
+  config:
+    import:
+      - nacos:${spring.application.name}-${spring.profiles.active}