4

我正在为 Google Glass 开发 Glassware。我正在尝试导入这些文件:

import com.google.api.client.json.jackson.JacksonFactory;
import com.google.api.services.oauth2.Oauth2;
import com.google.api.services.oauth2.model.Userinfo;

但我在他们身上遇到了错误。它们如下:

The import com.google.api.client.json.jackson cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved
The import com.google.api.services.oauth2 cannot be resolved

我不确定为什么会收到这些错误。我正在构建快速入门 java 项目。我的 Maven 依赖项如下:

C:\Users\Family3\.m2\repository\com\google\apis\google-api-services-mirror\v1-rev20-1.16.0-rc\google-api-services-mirror-v1-rev20-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\api-client\google-api-client\1.16.0-rc\google-api-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\oauth-client\google-oauth-client\1.16.0-rc\google-oauth-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client-jackson2\1.16.0-rc\google-http-client-jackson2-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\http-client\google-http-client\1.16.0-rc\google-http-client-1.16.0-rc.jar
C:\Users\Family3\.m2\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpclient\4.0.1\httpclient-4.0.1.jar
C:\Users\Family3\.m2\repository\org\apache\httpcomponents\httpcore\4.0.1\httpcore-4.0.1.jar
C:\Users\Family3\.m2\repository\xpp3\xpp3\1.1.4c\xpp3-1.1.4c.jar
C:\Users\Family3\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.1.3\jackson-core-2.1.3.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty\6.1.14\jetty-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\servlet-api-2.5\6.1.14\servlet-api-2.5-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-util\6.1.14\jetty-util-6.1.14.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jetty-plus\6.1.14\jetty-plus-6.1.14.jar
C:\Users\Family3\.m2\repository\geronimo-spec\geronimo-spec-jta\1.0.1B-rc4\geronimo-spec-jta-1.0.1B-rc4.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-2.1\6.1.14\jsp-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\eclipse\jdt\core\3.1.1\core-3.1.1.jar
C:\Users\Family3\.m2\repository\ant\ant\1.6.5\ant-1.6.5.jar
C:\Users\Family3\.m2\repository\org\mortbay\jetty\jsp-api-2.1\6.1.14\jsp-api-2.1-6.1.14.jar
C:\Users\Family3\.m2\repository\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-core-asl\1.9.11\jackson-core-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\org\codehaus\jackson\jackson-mapper-asl\1.9.11\jackson-mapper-asl-1.9.11.jar
C:\Users\Family3\.m2\repository\javax\servlet\servlet-api\2.5\servlet-api-2.5.jar
C:\Users\Family3\.m2\repository\commons-logging\commons-logging\1.1.2\commons-logging-1.1.2.jar
C:\Users\Family3\.m2\repository\commons-codec\commons-codec\1.7\commons-codec-1.7.jar
C:\Users\Family3\.m2\repository\com\google\guava\guava\14.0.1\guava-14.0.1.jar

为什么我会收到这些错误?我没有导入 .jar 吗?我找不到任何不应该包含的.jar,但可能有一个。谢谢您的帮助。

4

2 回答 2

5

将客户端库添加到项目中。

请参阅google-api-java-client 的下载和设置说明

于 2013-10-18T17:54:46.453 回答
-1

尝试添加:

<dependency>
   <groupId>com.google.apis</groupId>
   <artifactId>google-api-services-oauth2</artifactId>
   <version>{version}</version>
</dependency>         
于 2013-10-18T17:57:29.313 回答