From 41b51974dbbea6041163726f8ae24610e8b49af4 Mon Sep 17 00:00:00 2001
From: DerekYRC <15521077528@163.com>
Date: Thu, 7 Apr 2022 23:03:36 +0800
Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E6=88=90Feign=E7=AE=80=E5=8C=96?=
=?UTF-8?q?=E8=B0=83=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../pom.xml | 6 --
mini-spring-cloud-load-balancer/pom.xml | 1 -
mini-spring-cloud-openfeign/pom.xml | 65 +++++++++++++++++++
.../cloud/openfeign/EnableFeignClients.java | 18 +++++
.../github/cloud/openfeign/FeignClient.java | 17 +++++
.../openfeign/FeignClientFactoryBean.java | 52 +++++++++++++++
.../openfeign/FeignClientsRegistrar.java | 45 +++++++++++++
pom.xml | 8 +++
8 files changed, 205 insertions(+), 7 deletions(-)
create mode 100644 mini-spring-cloud-openfeign/pom.xml
create mode 100644 mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/EnableFeignClients.java
create mode 100644 mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClient.java
create mode 100644 mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClientFactoryBean.java
create mode 100644 mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClientsRegistrar.java
diff --git a/mini-spring-cloud-examples/mini-spring-cloud-consumer-examples/pom.xml b/mini-spring-cloud-examples/mini-spring-cloud-consumer-examples/pom.xml
index a9c5f04..a545464 100644
--- a/mini-spring-cloud-examples/mini-spring-cloud-consumer-examples/pom.xml
+++ b/mini-spring-cloud-examples/mini-spring-cloud-consumer-examples/pom.xml
@@ -34,12 +34,6 @@
mini-spring-cloud-load-balancer
-
- io.github.openfeign
- feign-core
- test
-
-
org.springframework.cloud
spring-cloud-starter-feign
diff --git a/mini-spring-cloud-load-balancer/pom.xml b/mini-spring-cloud-load-balancer/pom.xml
index 9a963e0..82a27f2 100644
--- a/mini-spring-cloud-load-balancer/pom.xml
+++ b/mini-spring-cloud-load-balancer/pom.xml
@@ -54,7 +54,6 @@
org.springframework.boot
spring-boot-starter-web
- test
diff --git a/mini-spring-cloud-openfeign/pom.xml b/mini-spring-cloud-openfeign/pom.xml
new file mode 100644
index 0000000..99a980a
--- /dev/null
+++ b/mini-spring-cloud-openfeign/pom.xml
@@ -0,0 +1,65 @@
+
+
+
+ mini-spring-cloud
+ com.github
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+
+ mini-spring-cloud-openfeign
+
+
+
+ com.github
+ mini-spring-cloud-load-balancer
+
+
+
+ io.github.openfeign
+ feign-core
+
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+
+ org.springframework.boot
+ spring-boot
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+ true
+
+
+
+ org.springframework.cloud
+ spring-cloud-commons
+
+
+
+ org.springframework.cloud
+ spring-cloud-context
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
\ No newline at end of file
diff --git a/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/EnableFeignClients.java b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/EnableFeignClients.java
new file mode 100644
index 0000000..3c51eb7
--- /dev/null
+++ b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/EnableFeignClients.java
@@ -0,0 +1,18 @@
+package com.github.cloud.openfeign;
+
+import org.springframework.context.annotation.Import;
+
+import java.lang.annotation.*;
+
+/**
+ * 启用Feign
+ *
+ * @author derek(易仁川)
+ * @date 2022/4/7
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@Import(FeignClientsRegistrar.class)
+public @interface EnableFeignClients {
+}
diff --git a/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClient.java b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClient.java
new file mode 100644
index 0000000..ffdaa7b
--- /dev/null
+++ b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClient.java
@@ -0,0 +1,17 @@
+package com.github.cloud.openfeign;
+
+/**
+ * Feign客户端注解
+ *
+ * @author derek(易仁川)
+ * @date 2022/4/7
+ */
+public @interface FeignClient {
+
+ /**
+ * 服务提供者应用名称
+ *
+ * @return
+ */
+ String value();
+}
diff --git a/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClientFactoryBean.java b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClientFactoryBean.java
new file mode 100644
index 0000000..2141931
--- /dev/null
+++ b/mini-spring-cloud-openfeign/src/main/java/com/github/cloud/openfeign/FeignClientFactoryBean.java
@@ -0,0 +1,52 @@
+package com.github.cloud.openfeign;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * 生成Feign客户端的FactoryBean
+ *
+ * @author derek(易仁川)
+ * @date 2022/4/7
+ */
+public class FeignClientFactoryBean implements FactoryBean
+
+
+ io.github.openfeign
+ feign-core
+ ${feign.version}
+