gpt4 book ai didi

docker - Spring Cloud 合约 stub jar 作为 http REST 端点

转载 作者:行者123 更新时间:2023-12-02 18:36:26 26 4
gpt4 key购买 nike

我正在尝试将 Spring 契约(Contract) stub jar 设置为带有使用者的胖 jar 或我的服务可以向其发送请求并最终接收评估响应的 http REST 端点。

理想情况下,我更喜欢后者,消费者可以运行 stub 来管理交互。我从消费者到本地生产者 stub 的测试按预期工作。当我将所需的注释添加到 stub 运行器的主类时,我的编译失败。我认为我缺少消费者将 stub 作为 http REST 端点运行或在其 m2 中识别所需的一些配置或设置。

应用程序编译失败,@EnableStubRunnerServer 提示以下内容:

ConsumerApplication.java:[8,60] package org.springframework.cloud.contract.stubrunner.server does not exist
ConsumerApplication.java:[15,2] cannot find symbol
[ERROR] symbol: class EnableStubRunnerServer

ConsumerApplication.java:
@SpringBootApplication
@EnableWebMvc
@EnableStubRunnerServer
@Slf4j

public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
}

application.properties(消费者):
stubrunner.ids=com.somecompany.somegroup:producer:0.0.1-SNAPSHOT:stubs:8081
stubrunner.stubsMode=REMOTE
server.ssl.key-store-password=password
server.ssl.key-password=password
server.ssl.trust-store-password=password
server.port=8081

Test.java: - 这个测试有效
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@AutoConfigureMockMvc
@AutoConfigureJsonTesters
@AutoConfigureStubRunner( ids = "com.somecompany.somegroup:producer:+:stubs:8081",
stubsMode = StubRunnerProperties.StubsMode.LOCAL)
@DirtiesContext
public class ContractControllerTest extends AbstractTest {

}

起居室:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>

最佳答案

由于您尝试将测试代码添加到主生产代码中,因此您必须更改

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
</dependency>

关于docker - Spring Cloud 合约 stub jar 作为 http REST 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55528051/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com