0

I have the following configuration:

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

And have the following test:

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

The error I get is Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client: theclient as if the application.yaml was not read. If I add, however, a config.properties file with the theclient.ribbon.listOfServers=http://server:8080, the tests works and passes.

With @TestPropertySource("classpath:application.yaml") I see in the logs propertySourceLocations = '{classpath:application.yaml}' but I will get the same error.

I also tried to disable ribbon, by adding:

spring:
  cloud:
    loadbalancer:
      ribbon:
        enable: false

but it won't work.

I appreciate your input and help.

marcovmx07
  • 23
  • 6
  • Is the client visible in the Service Registry that you communicate with? – OlgaMaciaszek Jan 26 '21 at 09:05
  • @OlgaMaciaszek, I am not using a service registry, the documentation says the client name is matched with what is configured on application.yaml. I suspect the test configuration ( `... @RestClientTest... @ImportAutoConfiguration`) is messing up with how spring picks up the client. – marcovmx07 Feb 18 '21 at 19:12

0 Answers0