我正在使用球衣客户端将数据推送到本地主机。这是我的代码 -
public CloudConnection(JSONObject jsonPush) throws ClientProtocolException, IOException, JSONException {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource webResource = client.resource(UriBuilder.fromUri("http://localhost/visual/savedata.php").build());
ClientResponse response = webResource.path("restPath").path("resourcePath").type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, jsonPush);
}
当我在 Eclipse 中执行此操作时,它工作正常,并且我的本地主机上的数据库使用 savedata.php 插入了一个记录。但是一旦我为我的项目制作了一个可运行的 jar 并运行它就会抛出错误 -
a message body writer for java type, class org.codehaus.jettison.json.JSONObject, and MIME media type, application/json was not found
从可运行的 jar 执行时,我怎样才能使其正常工作?