Я создал заглушку Spring Cloud Contract в проекте Spring Boot (spring-server
). Клиент, который хочет вызвать эту заглушку, не является проектом Spring и не может быть им. Если я запускаю следующее в клиенте:
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = {"uk.co.hadoopathome:spring-server:+:stubs:8093"},
stubsMode = StubRunnerProperties.StubsMode.LOCAL)
public class ContractTest {
@Test
public void testContractEndpoint() {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpGet = new HttpGet("http://localhost:8093/ac01");
CloseableHttpResponse response = httpclient.execute(httpGet);
String entity = EntityUtils.toString(response.getEntity());
assertEquals("ac01returned", entity);
response.close();
} catch (IOException ignored) {
}
}
}
тогда я получаю ошибку
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
Очевидно, у меня нет @SpringBootConfiguration
, так как это не проект Spring Boot.
Какой обходной путь здесь?