我在服務中遇到問題。 下面是我的服務用多值地圖發帖後致電
@POST
@Path("/config")
@Consumes(MediaType.APPLICATION_JSON)
public Response saveConfiguration(String name, MultivaluedMap<String,
Object> properties) {
return Response.ok().build();
}
而且我的測試情況是:
String payload = "{"name": "CRJ001",
"properties": {"expression": ["a + b"],
"baseClass": ["org.carlspring.strongbox.crontask.test.MyTask"]}}";
WebTarget resource = client.getClientInstance().target(path);
Response response = resource.request(MediaType.APPLICATION_JSON).
post(Entity.entity(payload, MediaType.APPLICATION_JSON));
int status = response.getStatus();
assertEquals("Failed to save!", Response.ok().build().getStatus(), status);
但我發現了:
[[FATAL] Method public javax.ws.rs.core.Response org.abc.rest.ConfigurationRestlet.
saveConfiguration(java.lang.String,javax.ws.rs.core.MultivaluedMap)
on resource class org.abc.rest.ConfigurationRestlet contains multiple
parameters with no annotation. Unable to resolve the injection source.;
請幫我這一點
什麼是'org.abc.rest.ConfigurationRestlet'? – 2016-05-31 06:43:42
它是休息服務類 – Yougesh
您應該在參數'name'上使用JAX-RS註釋。請求的哪部分映射在它上面? – 2016-05-31 07:48:53