我正在使用docs from blogs.oracle.com从Jersey开始进行REST调用。这是我的import语句,可以访问WebResource:
import com.sun.jersey.api.client.WebResource;
我收到错误消息“无法解析符号'客户端'”。我怎么能纠正这个?
请求信息更新:
以下是在我的安装上重现异常所需的完整代码:
package com.nc4.cdn.jcdn.jersey.resource;
import com.sun.jersey.api.*;
import com.sun.jersey.api.client.WebResource; //<==error on this line -- "Cannot resolve symbol 'Client'"
根据请求,这是我的库文件夹中所有文件的列表:
apache-maven-2.0.9.jar
asm-3.1.jar
classworlds-1.1.jar
commons-cli-1.0.jar
commons-httpclient-2.0.2.jar
commons-logging-1.0.4.jar
doxia-sink-api-1.0-alpha-10.jar
jdom-1.0.jar
jersey-core-1.0.jar
jersey-server-1.0.jar
jettison-1.3.8.jar
META-INF
jettison
jsch-0.1.27.jar
jsr311-api-1.0.jar
jtidy-4aug2000r7-dev.jar
junit-3.8.1.jar
maven-artifact-2.0.9.jar
maven-artifact-manager-2.0.9.jar
maven-core-2.0.9.jar
maven-error-diagnostics-2.0.9.jar
maven-model-2.0.9.jar
maven-monitor-2.0.9.jar
maven-plugin-api-2.0.jar
maven-plugin-descriptor-2.0.9.jar
maven-plugin-parameter-documenter-2.0.9.jar
maven-plugin-registry-2.0.9.jar
maven-profile-2.0.9.jar
maven-project-2.0.9.jar
maven-reporting-api-2.0.9.jar
maven-repository-metadata-2.0.9.jar
maven-settings-2.0.9.jar
maven-toolchain-2.0.9.jar
maven-wadl-plugin-1.0.jar
maven-wadl-plugin-1.0-sources.jar
plexus-container-default-1.0-alpha-9-stable-1.jar
plexus-interactivity-api-1.0-alpha-4.jar
plexus-utils-1.5.1.jar
slide-webdavlib-2.1.jar
stax-api-1.0.1.jar
xml
META-INF
wagon-file-1.0-beta-2.jar
wagon-http-lightweight-1.0-beta-2.jar
wagon-http-shared-1.0-beta-2.jar
wagon-provider-api-1.0-beta-2.jar
wagon-ssh-1.0-beta-2.jar
wagon-ssh-common-1.0-beta-2.jar
wagon-ssh-external-1.0-beta-2.jar
wagon-webdav-1.0-beta-2.jar
xercesImpl-2.6.1.jar
xml-apis-1.0.b2.jar
xml-im-exporter-1.1.jar
答案 0 :(得分:1)
您还需要导入Client类:
import com.sun.jersey.api.client.Client;
(大多数IDE可以自动为您组织导入)
您还需要在类路径中使用jersey-client-1.0.jar
答案 1 :(得分:0)
将导入语句更改为:
import org.glassfish.jersey.client.*;
......修好了。