java.lang.noclassdeffounderror: org/glassfish/hk2/api/servicelocatorfactory$createpolicy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34529121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:00:12  来源:igfitidea点击:

java.lang.noclassdeffounderror: org/glassfish/hk2/api/servicelocatorfactory$createpolicy

javarestjerseyglassfishhk2

提问by saivinod

Why am I getting error even though I added all the required jars. I am trying to build rest client using JERSEY

为什么即使我添加了所有必需的 jar 也会出错。我正在尝试使用 JERSEY 构建休息客户端

client=ClientBuilder.newClient();
response = client.target("https://XXX/rest/api/2/search?jql="+query).request("application/json").header(authorizationHeaderName, authorizationHeaderValue).get();

responseBody = response.readEntity(String.class);
JSONObject jsonObject = new JSONObject(responseBody);
JSONArray jsonArray = jsonObject.getJSONArray("issues");

added jars: JARs

补充罐: JAR文件

回答by Maruthi Shanmugam

ServiceLocatorFactory$createPolicy is part of the hk2-api 2.4.* and above. You are using a lower version of hk2-api.

ServiceLocatorFactory$createPolicy 是 hk2-api 2.4.* 及以上版本的一部分。您使用的是较低版本的 hk2-api。

Thanks

谢谢