Tencent / spring-cloud-tencent

Spring Cloud Tencent is a Spring Cloud based Service Governance Framework provided by Tencent.
Other
3.19k stars 492 forks source link

OpenFeign调用出现 Load balancer does not contain an instance for the service #790

Closed lhzsdnu closed 1 year ago

lhzsdnu commented 1 year ago

环境 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调用正常

SkyeBeFreeman commented 1 year ago

方便贴一下代码吗?

lhzsdnu commented 1 year ago

image

lhzsdnu commented 1 year ago

image

SkyeBeFreeman commented 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);
    }
}