Forráskód Böngészése

【新增】feign透传修改自动配置功能

zhuzhoutong 5 éve
szülő
commit
d703215199

+ 2 - 10
framework-boot/src/main/java/com/mrxu/framework/boot/feign/FeignAutoConfiguration.java

@@ -1,6 +1,6 @@
-package com.mrxu.framework.boot.feign;
+package com.mrxu.framework.boot.config;
 
 
-import com.mrxu.framework.boot.handle.UserInfoHandler;
+import com.mrxu.framework.boot.feign.FeignRequestInterceptor;
 import feign.RequestInterceptor;
 import feign.RequestInterceptor;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -27,12 +27,4 @@ public class FeignAutoConfiguration {
         return new FeignRequestInterceptor();
         return new FeignRequestInterceptor();
     }
     }
 
 
-    /**
-     * 用户信息拦截器
-     * @return 用户信息拦截器
-     */
-    @Bean
-    public UserInfoHandler userInfoHandler() {
-        return new UserInfoHandler();
-    }
 }
 }

+ 36 - 0
framework-boot/src/main/java/com/mrxu/framework/boot/config/WebMvcConfig.java

@@ -0,0 +1,36 @@
+package com.mrxu.framework.boot.config;
+
+import com.mrxu.framework.boot.handle.UserInfoHandler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+/**
+ * 功能概要:[mvc配置类] <br>
+ *
+ * @author zzt
+ * @date 2020/10/15
+ */
+@Configuration
+public class WebMvcConfig implements WebMvcConfigurer {
+
+    /**
+     * 用户信息拦截器
+     * @return 用户信息拦截器
+     */
+    @Bean
+    public UserInfoHandler userInfoHandler() {
+        return new UserInfoHandler();
+    }
+
+    /**
+     * 拦截器添加
+     * @param registry
+     */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(userInfoHandler()).addPathPatterns("/**");
+		WebMvcConfigurer.super.addInterceptors(registry);
+    }
+}

+ 4 - 0
framework-boot/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,4 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+com.mrxu.framework.boot.config.FeignAutoConfiguration,\
+com.mrxu.framework.boot.config.WebMvcConfig