我有以下配置:
@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}'
但我会得到同样的错误。
我还尝试禁用ribbon,方法是添加:
spring:
cloud:
loadbalancer:
ribbon:
enable: false
但这行不通。
我感谢你的投入和帮助。
暂无答案!
目前还没有任何答案,快来回答吧!