0

我有以下配置:

@SpringBootApplication
@EnableFeignClients
public class Application {
@FeignClient(name = "theclient")
public interface TheClient {
...
theclient:
  ribbon:
    listOfServers: http://server:8080

并进行以下测试:

@RunWith(SpringRunner.class)
@RestClientTest(TheClient.class)
@ImportAutoConfiguration(
        classes = {
                RibbonAutoConfiguration.class,
                FeignRibbonClientAutoConfiguration.class,
                FeignAutoConfiguration.class
        }
)
public class TheClientTest {
...

我得到的错误Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: theclient好像application.yaml没有被读取。但是,如果我添加一个config.properties带有 . 的文件theclient.ribbon.listOfServers=http://server:8080,则测试可以正常工作并通过。

我在@TestPropertySource("classpath:application.yaml")日志中看到,propertySourceLocations = '{classpath:application.yaml}'但我会得到同样的错误。

我还尝试通过添加以下内容来禁用功能区:

spring:
  cloud:
    loadbalancer:
      ribbon:
        enable: false

但它不会工作。

感谢您的意见和帮助。

4

0 回答 0