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

有个小Bug issues/I3854N
This commit is contained in:
zhangdaiscott
2021-02-21 09:44:13 +08:00
parent 386ae84941
commit 5aab4c855b
2 changed files with 16 additions and 15 deletions
@@ -175,7 +175,7 @@ export const JeecgThirdLoginMixin = {
this.bindingPhoneModal = false this.bindingPhoneModal = false
this.doThirdLogin(res.result) this.doThirdLogin(res.result)
} else { } else {
this.$message.$warning(res.message) this.$message.warning(res.message)
} }
}) })
}, },
@@ -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 {
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));
} }
} }