liriming
2024-12-03 97f3c16ac595493405e8cf76399dc703c088ef6f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
spring:
  application:
    name: gateway-server
 
  main:
    allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
 
  profiles:
    active: @profiles.active@
 
  config:
    import:
      - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置
      - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置
 
  cloud:
    nacos:
      server-addr: @nacos.server@ # Nacos 服务器地址
      username: @nacos.username@
      password: @nacos.password@
      discovery: # 【配置中心】配置项
        namespace: @profiles.active@
        group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
        metadata:
          version: @nacos.metadata.version@ # 服务实例的版本号,可用于灰度发布
          management.context-path: ${server.servlet.context-path}/actuator
      config: # 【注册中心】配置项
        namespace: @profiles.active@
        group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
 
    # Spring Cloud Gateway 配置项,对应 GatewayProperties 类
    gateway:
      # 路由配置项,对应 RouteDefinition 数组
      routes:
        ## system-server 服务
        - id: system-admin-api # 路由的编号
          uri: grayLb://system-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/system/**
          filters:
              - RewritePath=/admin-api/system/v3/api-docs, /v3/api-docs # 配置,保证转发到 /v3/api-docs
        - id: system-app-api # 路由的编号
          uri: grayLb://system-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/app-api/system/**
          filters:
              - RewritePath=/app-api/system/v3/api-docs, /v3/api-docs
        ## infra-server 服务
        - id: infra-admin-api # 路由的编号
          uri: grayLb://infra-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/infra/**
          filters:
              - RewritePath=/admin-api/infra/v3/api-docs, /v3/api-docs
        - id: infra-app-api # 路由的编号
          uri: grayLb://infra-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/app-api/infra/**
          filters:
              - RewritePath=/app-api/infra/v3/api-docs, /v3/api-docs
        - id: infra-spring-boot-admin # 路由的编号(Spring Boot Admin)
          uri: grayLb://infra-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin/**
        - id: infra-websocket # 路由的编号(WebSocket)
          uri: grayLb://infra-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/infra/ws/**
        ## bpm-server 服务
        - id: bpm-admin-api # 路由的编号
          uri: grayLb://bpm-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/bpm/**
          filters:
              - RewritePath=/admin-api/bpm/v3/api-docs, /v3/api-docs
        ## report-server 服务
        - id: report-admin-api # 路由的编号
          uri: grayLb://report-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/report/**
          filters:
            - RewritePath=/admin-api/report/v3/api-docs, /v3/api-docs
        - id: report-jimu # 路由的编号(积木报表)
          uri: grayLb://report-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/jmreport/**, /drag/**
        ## statistics-server 服务
        - id: statistics-admin-api # 路由的编号
          uri: grayLb://statistics-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/statistics/**
          filters:
            - RewritePath=/admin-api/statistics/v3/api-docs, /v3/api-docs # 配置,保证转发到 /v3/api-docs
        ## xxl-job
        - id: xxl-job-admin
          uri: grayLb://xxl-job-server
          predicates:
            - Path=/xxl-job-admin/**
        ## monitor
        - id: monitor-server
          uri: grayLb://monitor-server
          predicates:
            - Path=/iailab-monitor/**
        ## data-server 服务
        - id: data-admin-api # 路由的编号
          uri: grayLb://data-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/data/**
          filters:
            - RewritePath=/admin-api/data/v3/api-docs, /v3/api-docs
        ## model-server 服务
        - id: model-admin-api # 路由的编号
          uri: grayLb://model-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/model/**
          filters:
            - RewritePath=/admin-api/model/v3/api-docs, /v3/api-docs
        ## shasteel 服务
        - id: shasteel-admin-api # 路由的编号
          uri: grayLb://shasteel-server
          predicates: # 断言,作为路由的匹配条件,对应 RouteDefinition 数组
            - Path=/admin-api/shasteel/**
          filters:
            - RewritePath=/admin-api/shasteel/v3/api-docs, /v3/api-docs
      x-forwarded:
        prefix-enabled: true # 避免 Swagger 重复带上额外的 /admin-api/system 前缀
 
server:
  port: 48080
  servlet:
    session:
      timeout: 120s
 
logging:
  file:
    name: @log.path@/logs/${spring.application.name}.log # 日志文件名,全路径
 
knife4j:
  # 聚合 Swagger 文档,参考 https://doc.xiaominfo.com/docs/action/springcloud-gateway 文档
  gateway:
    enabled: true
    routes:
      - name: system-server
        service-name: system-server
        url: /admin-api/system/v3/api-docs
      - name: infra-server
        service-name: infra-server
        url: /admin-api/infra/v3/api-docs
      - name: bpm-server
        service-name: bpm-server
        url: /admin-api/bpm/v3/api-docs
      - name: data-server
        service-name: data-server
        url: /admin-api/data/v3/api-docs
      - name: model-server
        service-name: model-server
        url: /admin-api/model/v3/api-docs
      - name: report-server
        service-name: report-server
        url: /admin-api/report/v3/api-docs
--- #################### 平台相关配置 ####################
 
iailab:
  info:
    version: 1.0.0
 
# 服务端点检查
management:
  trace:
    http:
      enabled: true
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
 
# 日志文件配置
logging:
  level:
    org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示