为什么 Stub Runner 不以类路径模式启动 Wiremock 服务器?
Why Stub Runner is not booting up a Wiremock server in the Classpath mode?
我正在尝试 运行 使用 Spring Cloud Contract 的 Stub Runner 在我的消费者应用程序中进行一些测试。
我注意到当 stubsMode 属性 设置为 LOCAL
时。
@AutoConfigureStubRunner(
stubsMode = StubRunnerProperties.StubsMode.LOCAL,
ids = "com.example:spring-cloud-contract-producer:+:stubs:8090")
我的构建是成功的,因为嵌入式 Wiremock 实例启动并侦听该端口。
但是,如果我将 stubsMode 属性 更改为 CLASSPATH
,我的构建将失败,因为测试无法在该端口建立连接。
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8090/validate/prime-number": Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
根据 docs,这应该只会影响存根的下载方式:
StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick
stubs from the classpath
我在这里做错了什么?提前致谢!
如果你打开类路径模式,那么,顾名思义,你需要在你的类路径上有依赖项。带有存根的 jar 需要包含文档中描述的预定义结构。通常,在您的情况下,它将包含一个 META-INF/com.example/spring-cloud-contract-producer/mappings
文件夹,其中包含 WireMock 存根。如果您的类路径上没有生产者存根,则类路径模式将不起作用。
我正在尝试 运行 使用 Spring Cloud Contract 的 Stub Runner 在我的消费者应用程序中进行一些测试。
我注意到当 stubsMode 属性 设置为 LOCAL
时。
@AutoConfigureStubRunner(
stubsMode = StubRunnerProperties.StubsMode.LOCAL,
ids = "com.example:spring-cloud-contract-producer:+:stubs:8090")
我的构建是成功的,因为嵌入式 Wiremock 实例启动并侦听该端口。
但是,如果我将 stubsMode 属性 更改为 CLASSPATH
,我的构建将失败,因为测试无法在该端口建立连接。
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8090/validate/prime-number": Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
根据 docs,这应该只会影响存根的下载方式:
StubRunnerProperties.StubsMode.CLASSPATH (default value) - will pick stubs from the classpath
我在这里做错了什么?提前致谢!
如果你打开类路径模式,那么,顾名思义,你需要在你的类路径上有依赖项。带有存根的 jar 需要包含文档中描述的预定义结构。通常,在您的情况下,它将包含一个 META-INF/com.example/spring-cloud-contract-producer/mappings
文件夹,其中包含 WireMock 存根。如果您的类路径上没有生产者存根,则类路径模式将不起作用。