我尝试使用以下代码访问服务器:
WebTarget target = client.target(<uri>);
Invocation.Builder builder;
builder = target.request();
builder.header("Authorization", "Token token=<secret>");
builder.accept(MediaType.APPLICATION_JSON);
Response response = builder.buildGet().invoke();
我收到以下异常
Exception in thread "main" java.lang.NoSuchFieldError: WILDCARD_TYPE
at org.glassfish.jersey.message.internal.MediaTypes.<clinit> (MediaTypes.java:126)
at org.glassfish.jersey.message.internal.OutboundMessageContext.<clinit>(OutboundMessageContext.java:88)
at org.glassfish.jersey.client.JerseyInvocation$Builder.<init>(JerseyInvocation.java:165)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:214)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:59)
at com.peakhosting.pagerduty.Harvester.Harvest.main(Harvest.java:33)
来自pom.xml:
从pom.xml文件:
球衣:0-8-ea jersey-client:1.19 球衣客户:2.17 Jersey的服务器:2.17我没注意到jersey-client的两个版本。我想知道这是不是问题。 有人可以解释一下发生了什么吗?
谢谢, 罗布