Commit eb5a2f29 authored by 吴泽佳's avatar 吴泽佳

Merge branch 'v0.0.1-day-subject' of…

Merge branch 'v0.0.1-day-subject' of http://47.100.44.39:10001/tp-backend/feo-jobs into v0.0.1-day-subject
parents d897daa2 3b0385ff
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId> <artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version> <version>3.4.1</version>
<exclusions>
<exclusion>
<artifactId>mybatis-plus-extension</artifactId>
<groupId>com.baomidou</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
...@@ -63,6 +69,12 @@ ...@@ -63,6 +69,12 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<exclusions>
<exclusion>
<artifactId>jsr305</artifactId>
<groupId>com.google.code.findbugs</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!--feign--> <!--feign-->
...@@ -74,6 +86,10 @@ ...@@ -74,6 +86,10 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
</exclusion> </exclusion>
<exclusion>
<artifactId>commons-io</artifactId>
<groupId>commons-io</groupId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!--hystrix--> <!--hystrix-->
...@@ -85,6 +101,10 @@ ...@@ -85,6 +101,10 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
</exclusion> </exclusion>
<exclusion>
<artifactId>HdrHistogram</artifactId>
<groupId>org.hdrhistogram</groupId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
...@@ -103,6 +123,12 @@ ...@@ -103,6 +123,12 @@
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId> <artifactId>pagehelper</artifactId>
<exclusions>
<exclusion>
<artifactId>jsqlparser</artifactId>
<groupId>com.github.jsqlparser</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
......
package com.tanpu.feo.feojob.feign;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Map;
/**
* @description: 透传spring 头信息
* @author: wanglei
* @created: 2020/05/08 11:55
*/
@Slf4j
@Component
public class MyFeignInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate template) {
HttpServletRequest request = getHttpServletRequest();
if (request != null) {
Map<String, Collection<String>> feignHeaders = template.headers();
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
// 不覆盖feign的头信息
if (!feignHeaders.containsKey(name)) {
template.header(name, request.getHeader(name));
}
}
log.debug("添加后的头信息:{}", template.headers());
} else {
log.debug("没有添加feign头信息");
}
}
/**
* 如果不是从controller过来的请求(例如定时器等),是没有request对象的
*/
private HttpServletRequest getHttpServletRequest() {
try {
return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
} catch (Exception e) {
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment