Sto tentando di implementare un client semplice a riposo facile, ma ricevo un errore che dice "È necessario utilizzare almeno uno, ma non più di una annotazione del metodo http ". Nell'implementazione del mio server, ho aggiunto un'annotazione http sul mio metodo.È necessario utilizzare almeno uno, ma non più di un'annotazione del metodo http su per client proxy reaseasy
@Path("/")
public class TestResource
{
@GET
@Path("/domain/{value}")
public String get(@PathParam("value") final String value) {
return "Hello" + value;
}
}
ho il debug attraverso, la prima volta non è colpire l'eccezione di runtime, tuttavia, si sta facendo una seconda chiamata ad esso e in mancanza, non so perché e come.
Il mio cliente come test JUnit:
@Test
public void testPerformRestEasy() {
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target("http://localhost:8080/");
TestResource proxy = target.proxy(TestResource.class);
String response = proxy.get("user");
Assert.assertEquals("Hellouser", response);
}
Il codice in cui si sta venendo a mancare
private static <T> ClientInvoker createClientInvoker(Class<T> clazz, Method method, ResteasyWebTarget base, ProxyConfig config)
{
Set<String> httpMethods = IsHttpMethod.getHttpMethods(method);
if (httpMethods == null || httpMethods.size() != 1)
{
throw new RuntimeException("You must use at least one, but no more than one http method annotation on: " + method.toString());
}
ClientInvoker invoker = new ClientInvoker(base, clazz, method, config);
invoker.setHttpMethod(httpMethods.iterator().next());
return invoker;
}
Errore:
java.lang.RuntimeException: You must use at least one, but no more than one http method annotation on: public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
at org.jboss.resteasy.client.jaxrs.ProxyBuilder.createClientInvoker(ProxyBuilder.java:76)
at org.jboss.resteasy.client.jaxrs.ProxyBuilder.proxy(ProxyBuilder.java:52)
at org.jboss.resteasy.client.jaxrs.ProxyBuilder.build(ProxyBuilder.java:120)
at org.jboss.resteasy.client.jaxrs.internal.ClientWebTarget.proxy(ClientWebTarget.java:72)
Qualcuno sa qual è il problema qui?
Stai ancora affrontando il problema? –
sì. Ho appena aggiunto l'annotazione prodotta al mio file di risorse, ma non ha funzionato. – LifeStartsAtHelloWorld
Qualcuno ha qualche idea su come risolverlo? L'altro approccio che posso adottare è il client restacle e apache invece del proxy reasteasy. Sarei felice di usare proxy resteasy però. – LifeStartsAtHelloWorld