我正在 Dropwizard REST 应用程序中实现 Dropwizard 客户端。 我正在关注他们的User Manual .
尝试将客户端注册到 Jersey 环境时但找不到类ExternalServiceResource
@Override
public void run(ExampleConfiguration config,
Environment environment) {
final HttpClient httpClient = new HttpClientBuilder(environment).using(config.getHttpClientConfiguration())
.build();
environment.jersey().register(new ExternalServiceResource(httpClient));
}
最佳答案
我认为ExternalServiceResource是一个例子,但它看起来像:
@Path("/your/path")
public class ExternalServiceResource {
private final HttpClient client;
public ExternalServiceResource(HttpClient client) {
this.client = client;
}
@GET
public String doStuff() {
return /* use client to make some call */;
}
}
您可以输入任何您想要的名称。创建资源的唯一要求是 @Path 注释,您必须将其放在类级别,以及一些方法 @GET、@POST...
关于jersey - 在 Dropwizard 应用程序中将 http 客户端注册到 jersey 环境时无法解析符号ExternalServiceResource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30914683/