对于类型Mirror.Accounts.Insert,方法execute()是未定义的 [英] The method execute() is undefined for the type Mirror.Accounts.Insert

查看:129
本文介绍了对于类型Mirror.Accounts.Insert,方法execute()是未定义的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java和Eclipse IDE为Google Glass Mirror API创建服务器端动态Web项目.在我的Web项目中,WEB-INF下有一个lib文件夹

I am creating a server side Dynamic Web Project using Java and Eclipse IDE for Google Glass Mirror API. In my web project I have a lib folder under WEB-INF

在lib文件夹中,我添加了以下.jar文件

In the lib folder i have added the following .jar files

  • google-api-client-1.18.0-rc-sources.jar

  • google-api-client-1.18.0-rc-sources.jar

google-api-services-mirror-v1-rev66-1.19.0.jar

google-api-services-mirror-v1-rev66-1.19.0.jar

google-collections-1.0-rc2.jar

google-collections-1.0-rc2.jar

google-http-client-1.18.0-rc.jar

google-http-client-1.18.0-rc.jar

google-http-client-jackson-1.19.0.jar

google-http-client-jackson-1.19.0.jar

我的服务器端代码是

 @SuppressWarnings("serial")
    public class GlassAuthenticateUser extends HttpServlet{

public static Mirror getMirrorService() throws GeneralSecurityException,
IOException, URISyntaxException {
    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();

    GoogleCredential credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
    .setServiceAccountScopes(MIRROR_ACCOUNT_SCOPES)
    .setServiceAccountPrivateKeyFromP12File(
            new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
            .build();
    Mirror service = new Mirror.Builder(httpTransport, jsonFactory, null)
    .setHttpRequestInitializer(credential).build();
    return service;
}

public static void createAccount(Mirror mirror, String userToken, String accountName,
        String authTokenType, String authToken) {
    try {
        Account account = new Account();
        List<AuthToken> authTokens = Lists.newArrayList(
                new AuthToken().setType(authTokenType).setAuthToken(authToken));
        account.setAuthTokens(authTokens);
        mirror.accounts().insert(
                userToken, ACCOUNT_TYPE, accountName, account).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
}


public void doGet(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException{

     //TO DO             
     }
}

}

我遇到以下错误

对于Mirror.Accounts.Insert类型,方法execute()未定义

The method execute() is undefined for the type Mirror.Accounts.Insert

为什么会这样?我已经下载了最新的Google API Java客户端,并在我的项目中使用了它们.但是,它也无法解析GoogleCredential

Why is that so? I have download the latest Google API java client and used them in my project. However, it is unable to also resolve the GoogleCredential class

任何人都可以建议我添加哪些.jar文件来解决此问题?

Can anyone suggest which .jar files should I be adding to resolve this issue?

推荐答案

当您需要类jar时,您似乎拥有google-api-client-1.18.0-rc的源jar.您应该可以从 https下载最新的捆绑软件://code.google.com/p/google-api-java-client/wiki/Downloads?tm = 2 ,然后从下载的zip文件中提取google-api-java-client/libs/google-api-client-1.18.0-rc.jar.

It looks like you have the source jar for google-api-client-1.18.0-rc, when you need the class jar. You should be able to download the latest bundle from https://code.google.com/p/google-api-java-client/wiki/Downloads?tm=2 and then extracting google-api-java-client/libs/google-api-client-1.18.0-rc.jar from the downloaded zip file.

这篇关于对于类型Mirror.Accounts.Insert,方法execute()是未定义的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆