diff --git a/README.md b/README.md
index 98ae2ce1..7fc5dccc 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@
* 容器改动 Tomcat 改为 并发性能更好的 undertow
* 代码生成模板 改为适配 Mybatis-Plus 的代码
* 项目修改为 maven多环境配置
+* 集成 Feign 接口化管理 Http 请求(如三方请求 支付,短信,推送等)
* 升级MybatisPlus 3.4.2
* 增加demo模块示例(给不会增加模块的小伙伴做参考)
* 同步升级 3.3
diff --git a/pom.xml b/pom.xml
index 2b8a33f1..41cda320 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,8 @@
0.9.1
3.4.2
5.4.0
+ 2.2.6.RELEASE
+ 11.0
@@ -183,6 +185,18 @@
${hutool.version}
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+ ${feign.version}
+
+
+
+ io.github.openfeign
+ feign-okhttp
+ ${feign-okhttp.version}
+
+
com.ruoyi
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
index 3ae6f96d..4c87cc8d 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -3,12 +3,14 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 启动程序
*
* @author ruoyi
*/
+@EnableFeignClients
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 57a93445..a2c19500 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -190,3 +190,13 @@ xss:
excludes: /system/notice/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
+
+feign:
+ # 开启压缩
+ compression:
+ request:
+ enabled: true
+ response:
+ enabled: true
+ okhttp:
+ enabled: true
\ No newline at end of file
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 8d4f57b4..4d55fb92 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -136,6 +136,16 @@
lombok
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+ io.github.openfeign
+ feign-okhttp
+
+
\ No newline at end of file
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/FeignTestController.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/FeignTestController.java
new file mode 100644
index 00000000..f4c5f449
--- /dev/null
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/controller/FeignTestController.java
@@ -0,0 +1,24 @@
+package com.ruoyi.demo.controller;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.demo.feign.FeignTestService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
+@RestController
+@RequestMapping("/feign/test")
+public class FeignTestController {
+
+ private final FeignTestService feignTestService;
+
+ @GetMapping("/search/{wd}")
+ public AjaxResult search(@PathVariable String wd) {
+ String search = feignTestService.search(wd);
+ return AjaxResult.success("操作成功",search);
+ }
+}
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/FeignTestService.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/FeignTestService.java
new file mode 100644
index 00000000..4945f596
--- /dev/null
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/FeignTestService.java
@@ -0,0 +1,13 @@
+package com.ruoyi.demo.feign;
+
+import com.ruoyi.demo.feign.fallback.FeignTestFallback;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@FeignClient(name = "baidu",url = "http://www.baidu.com",fallback = FeignTestFallback.class)
+public interface FeignTestService {
+
+ @GetMapping("/s")
+ String search(@RequestParam("wd") String wd);
+}
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/FeignTestFallback.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/FeignTestFallback.java
new file mode 100644
index 00000000..f2012f96
--- /dev/null
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/FeignTestFallback.java
@@ -0,0 +1,12 @@
+package com.ruoyi.demo.feign.fallback;
+
+
+import com.ruoyi.demo.feign.FeignTestService;
+
+public class FeignTestFallback implements FeignTestService {
+
+ @Override
+ public String search(String wd) {
+ return null;
+ }
+}
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/package-info.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/package-info.java
new file mode 100644
index 00000000..47983a0e
--- /dev/null
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/fallback/package-info.java
@@ -0,0 +1 @@
+package com.ruoyi.demo.feign.fallback;
\ No newline at end of file
diff --git a/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/package-info.java b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/package-info.java
new file mode 100644
index 00000000..91e4b4a5
--- /dev/null
+++ b/ruoyi-demo/src/main/java/com/ruoyi/demo/feign/package-info.java
@@ -0,0 +1 @@
+package com.ruoyi.demo.feign;
\ No newline at end of file
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FeignConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FeignConfig.java
new file mode 100644
index 00000000..cdb0c8be
--- /dev/null
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FeignConfig.java
@@ -0,0 +1,55 @@
+package com.ruoyi.framework.config;
+
+import feign.*;
+import okhttp3.ConnectionPool;
+import okhttp3.OkHttpClient;
+import org.springframework.boot.autoconfigure.AutoConfigureBefore;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.cloud.openfeign.FeignAutoConfiguration;
+import org.springframework.cloud.openfeign.support.SpringMvcContract;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.concurrent.TimeUnit;
+
+@Configuration
+@ConditionalOnClass(Feign.class)
+@AutoConfigureBefore(FeignAutoConfiguration.class)
+public class FeignConfig {
+
+ @Bean
+ public OkHttpClient okHttpClient(){
+ return new OkHttpClient.Builder()
+ .readTimeout(60, TimeUnit.SECONDS)
+ .connectTimeout(60, TimeUnit.SECONDS)
+ .writeTimeout(120, TimeUnit.SECONDS)
+ .connectionPool(new ConnectionPool())
+ .build();
+ }
+
+ @Bean
+ public Feign.Builder feignBuilder() {
+ return Feign.builder();
+ }
+
+ @Bean
+ public Contract feignContract() {
+ return new SpringMvcContract();
+ }
+
+ @Bean
+ public Logger.Level feignLoggerLevel() {
+ return Logger.Level.BASIC;
+ }
+
+ @Bean
+ public Request.Options feignRequestOptions() {
+ return new Request.Options(10, TimeUnit.SECONDS, 60,TimeUnit.SECONDS,true);
+ }
+
+ @Bean
+ public Retryer feignRetry() {
+ return new Retryer.Default();
+ }
+
+}
\ No newline at end of file