Commit 766c48bd by zhangdaiscott

feign 动态创建client,拦截器执行多次 #2275

parent d16520cc
...@@ -35,11 +35,7 @@ public class JeecgFeignService implements IJeecgFeignService { ...@@ -35,11 +35,7 @@ public class JeecgFeignService implements IJeecgFeignService {
.encoder(encoder) .encoder(encoder)
.decoder(decoder) .decoder(decoder)
.contract(contract); .contract(contract);
}
@Override
public <T> T newInstance(Class<T> clientClass, String serviceName) {
builder.requestInterceptor(requestTemplate -> { builder.requestInterceptor(requestTemplate -> {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (null != attributes) { if (null != attributes) {
...@@ -54,6 +50,11 @@ public class JeecgFeignService implements IJeecgFeignService { ...@@ -54,6 +50,11 @@ public class JeecgFeignService implements IJeecgFeignService {
requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token); requestTemplate.header(CommonConstant.X_ACCESS_TOKEN, token);
} }
}); });
}
@Override
public <T> T newInstance(Class<T> clientClass, String serviceName) {
return builder.target(clientClass, String.format("http://%s/", serviceName)); return builder.target(clientClass, String.format("http://%s/", serviceName));
} }
} }
\ No newline at end of file
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