keyfil/文档/基础组件/feign/20250605-engine-starter-feign-2.0.1.md
liuxiaohua b0bb0a3568
All checks were successful
Publish to Confluence / confluence (push) Successful in 37s
[2025-06-26] 重新同步说明文档
2025-06-26 15:03:14 +08:00

108 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Space: qifu -->
<!-- Parent: 后端技术&知识&规范 -->
<!-- Parent: 技术方案 -->
<!-- Parent: 基建 -->
<!-- Parent: 00-基础组件 -->
<!-- Parent: 00-EngineStarterFeign使用指南 -->
<!-- Title: 20250605-engine-starter-feign-2.0.1 -->
<!-- Macro: :anchor\((.*)\):
Template: ac:anchor
Anchor: ${1} -->
<!-- Macro: \!\[.*\]\((.+)\)\<\!\-\- width=(.*) \-\-\>
Template: ac:image
Url: ${1}
Width: ${2} -->
<!-- Macro: \<\!\-\- :toc: \-\-\>
Template: ac:toc
Printable: 'false'
MinLevel: 2
MaxLevel: 4 -->
<!-- Include: 杂项/声明文件.md -->
<!-- :toc: -->
# engine-starter-feign 使用教程Deprecated
- <font color="red">该版本存在BUG请使用 2.0.2 版本</font>
- 在存在 RequestInterceptor 的情况下token 无法向下游透传的BUG
> 基于 Feign 的通用封装
> 具体使用可参考 [engine-sample > engine-sample-starter-web](../engine-sample/engine-sample-starter-web)
## 功能特性
- [X] 请求头添加内部请求标识 `X-QiFu-From-In: true`
- [X] 请求头透传
- [X] 请求结果解析映射(解封装 `Result`
- [X] 添加请求头透传
-------
## 快速使用
- **注意:** `qifu-saas-parent >= 2.0.1-SNAPSHOT`
- **注意:** 启动类 `@ComponentScan` 需要变更为如下形式
- ```java
@ComponentScan(value = "com.yuanmeng.*",
excludeFilters = {
@ComponentScan.Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@ComponentScan.Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class)
})
@SpringBootApplication
public class SampleStarterWebApplication {
public static void main(String[] args) {
SpringApplication.run(SampleStarterWebApplication.class, args);
}
}
```
### 添加依赖
```xml
<dependency>
<groupId>com.yuanmeng.engine</groupId>
<artifactId>engine-starter-feign</artifactId>
</dependency>
```
### 添加兼容包(可选)
- 项目中存在 `web-core` 时需要添加兼容包
```xml
<dependency>
<groupId>com.yuanmeng.engine</groupId>
<artifactId>engine-starter-compatible-feign</artifactId>
</dependency>
```
------
## 完整默认配置文件
```yaml
yuanmeng:
feign:
#- 开启feign自动配置
enable: true
#- 开启请求头内部标识
enable-contract: true
#- 开启旧包兼容
enable-ignore: true
#- 开启结果解析
enable-decoder: true
#- 开启请求头传递
enable-interceptor: true
#- 链接超时时间
connect-timeout: 10
connect-time-unit: seconds
#- 读取超时时间
read-timeout: 60
read-time-unit: seconds
```