java - Eclipse 未导入 com.google.api.client。进口?

标签 java eclipse spring-boot google-calendar-api

我正在尝试将 Google 的日历 API 实现到我的 Eclipse 中的 Spring Boot 项目中。我正在关注这个Java tutorial from the Google Developers' website

我正在执行第 3 步,我要复制代码,但是所有 Google API 导入都存在错误:

enter image description here

我得到的错误:

The import com.google cannot be resolved

导致错误的 Gradle 文件: enter image description here

更新: 我将以下内容添加到 Pom 文件中,它删除了几乎所有导入错误:

    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-calendar</artifactId>
        <version>v3-rev224-1.22.0</version>
    </dependency>

但是,以下两个导入仍然有错误:

import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;

import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;

最佳答案

你不能同时使用 gradle 和 maven。使用 gradlepom

如您所提到的,删除 gradle 构建文件并在 pom.xml 中添加依赖项。

然后转到maven ==>更新项目

这应该下载依赖项并修复错误。

关于java - Eclipse 未导入 com.google.api.client。进口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51504370/

相关文章:

java - 将二维数组变量加载到类实例中

java - Eclipse中加入JProgressBar和JTextArea(批量运行控制台)

spring-boot - 白名单 '/' 端点不适用于 Spring Security 6

java - 无效的赋值运算符 加、减、除、乘符号错误

java - 并发修改异常;无法修复

java - 模拟器运行缓慢

java - 加快 Eclipse 中调试的速度

java - 成功登录后 Spring Boot Security 重定向 - 未定义

spring-boot - Spring-Kafka 中的 poll() 和 commitAsync()

java - 使用法式java格式化时间