gpt4 book ai didi

jersey - 在 Dropwizard 中运行测试时没有安装 ServiceLocatorGenerator 错误

转载 作者:行者123 更新时间:2023-12-03 17:18:20 29 4
gpt4 key购买 nike

我已经在我的项目中升级了 Dropwizard 并在运行单元测试时遇到了问题,虽然服务启动工作正常并且所有 API 都运行正常,但只有在运行测试时才会出现问题,这是我的版本:

Dropwizard: 1.1.0
Jersey: 2.25.1
Guice: 4.1.0
hk2-api: 2.5.0-b36
hk2-utils: 2.5.0-b36
javax.ws.rs-api : 2.1-m05

以下是我运行“mvn test”时的错误
java.lang.RuntimeException: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:153)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:121)
at javax.ws.rs.core.Response$ResponseBuilder.newInstance(Response.java:848)
at javax.ws.rs.core.Response.status(Response.java:590)
at javax.ws.rs.core.Response.status(Response.java:601)
at javax.ws.rs.core.Response.ok(Response.java:622)
...... ** some more lines here **
Caused by: java.lang.ClassNotFoundException: Provider org.glassfish.jersey.internal.RuntimeDelegateImpl could not be instantiated: java.lang.IllegalStateException: It appears there is no ServiceLocatorGenerator installed.
at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:123)
at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:226)
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:137)

最佳答案

调用 JerseyGuiceUtils在运行测试或应用程序可以提供帮助之前。

static {
JerseyGuiceUtils.install((s, serviceLocator) -> null);
}
来源: https://github.com/dropwizard/dropwizard/issues/1772

关于jersey - 在 Dropwizard 中运行测试时没有安装 ServiceLocatorGenerator 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43452609/

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