Java Gmail API获取消息';无法解析方法execute()';
我正在尝试为用户运行示例java代码。但是,“execute()”方法上的my IDE(IntelliJ)错误: '无法解析方法execute()' 我有必要的依赖项,google-api-services-gmail-v1-rev43-1.2.2.0.jar。我还缺少另一种依赖吗Java Gmail API获取消息';无法解析方法execute()';,java,api,intellij-idea,gmail,Java,Api,Intellij Idea,Gmail,我正在尝试为用户运行示例java代码。但是,“execute()”方法上的my IDE(IntelliJ)错误: '无法解析方法execute()' 我有必要的依赖项,google-api-services-gmail-v1-rev43-1.2.2.0.jar。我还缺少另一种依赖吗 /** * List all Messages of the user's mailbox matching the query. * * @param service Authorized Gm
/**
* List all Messages of the user's mailbox matching the query.
*
* @param service Authorized Gmail API instance.
* @param userId User's email address. The special value "me"
* can be used to indicate the authenticated user.
* @param query String used to filter the Messages listed.
* @throws IOException
*/
public static List<Message> listMessagesMatchingQuery(Gmail service, String userId,String query) throws IOException {
ListMessagesResponse response = service.users().messages().list(userId).setQ(query).execute();
/**
*列出与查询匹配的用户邮箱的所有邮件。
*
*@param服务授权Gmail API实例。
*@param userId用户的电子邮件地址。“我”的特殊价值
*可用于指示经过身份验证的用户。
*@param查询字符串用于筛选列出的消息。
*@抛出异常
*/
公共静态列表listMessagesMatchingQuery(Gmail服务、字符串用户ID、字符串查询)引发IOException{
ListMessagesResponse response=service.users().messages().list(userId).setQ(query.execute();
错误:无法解析方法execute()compile我遇到了相同的问题。
尝试在gradle文件中添加此依赖项,它解决了我的问题
编译'com.google.api:googleapi服务gmail:v1-rev48-1.22.0'