[英]Spring Cloud Contract tests work with Maven but not when run with JUnit
I have a Maven project with two modules, one for the producer and another for consumer .我有一个包含两个模块的 Maven 项目,一个用于生产者,另一个用于消费者。
Project
-- Producer module
-- Consumer module
The consumer contains a dependency to the producer stubs, ie消费者包含对生产者存根的依赖,即
<dependency>
<groupId>com.example</groupId>
<artifactId>producer-application</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>stubs</classifier>
<scope>test</scope>
</dependency>
and the integration tests are configured so StubRunner
uses classpath scanning, ie并且配置了集成测试,以便StubRunner
使用类路径扫描,即
@AutoConfigureStubRunner(
stubsMode = StubRunnerProperties.StubsMode.CLASSPATH,
ids = "com.example:producer-application:+:8090"
)
During build, the integration tests for the consumer are executed correctly but if I try to run the tests locally with JUnit through the IDE (IntelliJ), the stubs are not found and tests fail.在构建期间,消费者的集成测试被正确执行,但如果我尝试通过 IDE (IntelliJ) 使用 JUnit 在本地运行测试,则找不到存根并且测试失败。
Is this an issue on how the project is structured?这是关于项目结构的问题吗? If so, is there something I can change to have it run without changing the code?如果是这样,是否可以更改某些内容以使其在不更改代码的情况下运行?
Classpath will not work from ide cause eg Intellij does not add the stubs jar to the classpath.类路径在 ide 中不起作用,例如 Intellij 不会将存根 jar 添加到类路径中。 It's a known issue with the ides.这是 ide 的一个已知问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.