Closed lhzsdnu closed 1 year ago
方便贴一下代码吗?
@lhzsdnu 我这边尝试是正常的,在polaris-discovery-example
项目内运行如下单测代码:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DiscoveryCallerService.class)
public class DiscoveryCalleeServiceTest {
@Autowired
private DiscoveryCalleeService discoveryCalleeService;
@Test
public void testFeign() {
int val = discoveryCalleeService.sum(1, 2);
System.out.println(val);
assertThat(val).isEqualTo(3);
}
}
环境 Spring Boot 2.7.7、Spring Cloud 2021.0.5、Spring Cloud Tencent 1.8.1-2021.0.3
问题 使用OpenFeign调用,通过接口调用正常,通过@Test调用报错Load balancer does not contain an instance for the service 如果先使用RestTemplate调用,本地生成缓存后,再使用OpenFeign通过@Test调用正常