文章目录
- 引言
- I Spring Cloud Gateway 跨域配置
- 1.1 网关统一处理:配置文件-推荐
- 1.2 网关统一处理:配置类方式
- 1.3 微服务处理,网关侧不用处理CORS。
- 1.4 子服务依赖配置
- 1.5 网关服务的依赖配置
- II 跨服务请求日志跟踪
- 2.1 feign 依赖配置
- 2.2 feign子模块将请求头中的参数,全部作为 feign 请求头参数传递
- 2.3 将MDC中request_id传入header
- 2.4 feign.RetryableException: too many bytes written executing POST
- 2.5 声明FeignClients
- 2.6 logback管理日志
- III Mdc工具类
- 3.1 RequestIdMdcUtil
- 3.2 封装线程池任务执行器,在任务提交时,会将父线程的request_id,带入子线程
- 3.3 线程池
引言
- 网关统一处理跨域配置,后端服务和nginx无需处理跨域问题。
- 利用org.slf4j.MDC存储请求ID,进行跨服务请求跟踪。
- logback管理日志
日志格式:
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{request_id}] %-5level %logger{50} - %msg%n"/>
I Spring Cloud Gateway 跨域配置
java.lang.IllegalArgumentException: When allowCredentials is true,allowedOrigins cannot contain the special value "*"since that cannot be set on the "Access-Control-Allow-Origin"response header. To allow credentials to a set of origins, list them explicitly or consider using "allow