[英]spring cloud contract - Feign Clients
使用Spring雲合約來驗證我的生產者和消費者之間的合約。 在我的使用者控制器中,我正在使用Feign客戶端調用另一種微服務方法來獲取一些數據。 但是現在在春季雲合同中,對這種微服務進行存根調用是不可能的。
將Spring Cloud與Netflix OSS結合使用。
配置服務和尤里卡已啟動。 現在,我在8090端口本地安裝了生產者。使用Feign客戶端的消費者致電生產者以獲取一些數據。 現在我收到500錯誤。 這表明找不到URL。 最接近的匹配是/ ping。 我相信Feign客戶端無法嘲笑,這是以某種方式嘗試與eureka而非本地安裝的生產者建立連接。 你能幫我嗎
任何例子或任何想法都將是偉大的。
謝謝
可能是的,這是我執行的JUnit測試( ParticipantsService
使用Feign Client)
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureStubRunner(ids = {"com.ryanjbaxter.spring.cloud:ocr-participants:+:stubs"}, workOffline = true)
@DirtiesContext
@ActiveProfiles("test")
public class OcrRacesApplicationTestsBase {
@Autowired
protected ParticipantsService participantsService;
private List<Participant> participants = new ArrayList<>();
//Hack to work around https://github.com/spring-cloud/spring-cloud-commons/issues/156
static {
System.setProperty("eureka.client.enabled", "false");
System.setProperty("spring.cloud.config.failFast", "false");
}
@Before
public void setup() {
this.participants = new ArrayList<>();
this.participants.add(new Participant("Ryan", "Baxter", "MA", "S", Arrays.asList("123", "456")));
this.participants.add(new Participant("Stephanie", "Baxter", "MA", "S", Arrays.asList("456")));
}
@After
public void tearDown() {
this.participants = new ArrayList<>();
}
@Test
public void contextLoads() {
List<Participant> participantList = participantsService.getAllParticipants();
assertEquals(participants, participantList);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.