[xuxueli/xxl-job]spring cloud整合xxx-job 无法调用到Feign接口

2021-10-28 768 views
4

core版本是2.3.0 cloud版本是2020.0.3 boot版本是2.4.6 在XxlJob任务方法里使用feign接口一直卡住无动作 直到出现 >>>>>>>>>>> xxl-job JobThread stoped, hashCode:Thread[Thread-42,10,main]

已单独测试过在同服务里单独使用feign接口是正常的,在job方法里就有问题

回答

7

具体查看了下日志 RequestAttributes attributes = RequestContextHolder.getRequestAttributes(); 这一行获取不到,空指针了,这个该怎么解决。。。

6

用client

0

RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(),true);

8

请问这个问题解决的了吗

5

可以在代码前面加一句: RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));