Wiremock 依赖项不导入类

问题描述 投票:0回答:2

我正在尝试使用 Wiremock 作为我的 spring api。 我正在使用 Java 17。

我正在使用这个依赖项

<dependency>
    <groupId>com.github.tomakehurst</groupId>
    <artifactId>wiremock-standalone</artifactId>
    <version>2.27.2</version>
    <scope>test</scope>
</dependency>

我正在尝试导入 WireMockServer 类

我尝试保存 pom.xml,清理并启动项目,更新项目,但它仍然不会导入我想要的类或导入中的其他任何内容,只是不断告诉我我需要创建该类

我的 MockServerConfig.java 类中的代码是

public class MockServerConfig extends WireMockServer {


}
spring-boot maven dependencies wiremock mockserver
2个回答
1
投票

具有

<scope>test</scope>
的依赖项只能在测试中使用。删除范围以在其他地方使用它。


0
投票

我遇到了同样的问题,即使我的范围没有设置,导入也没有解决,即

<dependency>
    <groupId>org.wiremock</groupId>
    <artifactId>wiremock-standalone</artifactId>
    <version>3.8.0</version>
</dependency>

我通过添加范围编译解决了这个问题,即

<dependency>
    <groupId>org.wiremock</groupId>
    <artifactId>wiremock-standalone</artifactId>
    <version>3.8.0</version>
    <scope>compile</scope>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.