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