You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maven项目中google-api-client与Google Sheets API版本冲突求助

解决google-api-client 2.x与Google Sheets API版本冲突的问题

问题出在你使用的Google Sheets API版本(v4-rev614-1.18.0-rc)的版本校验逻辑存在缺陷——它错误地将2.x系列的google-api-client判定为低于要求的1.15版本。这是因为旧版本的Sheets API是针对1.x系列的google-api-client开发的,其版本校验逻辑没有适配2.x的大版本号格式。

要在不降级google-api-client的前提下解决问题,只需将Google Sheets API升级到适配2.x版本google-api-client的版本即可:

  • 替换你的Sheets API依赖版本,选择核心版本为2.x的发行版(Google的API服务版本命名规则为v4-revXXXX-<核心版本>,核心版本需与google-api-client的大版本匹配)。例如使用适配的新版本:
<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-sheets</artifactId>
    <version>v4-rev20240526-2.0.0</version>
</dependency>
  • (可选)使用Maven的dependencyManagement统一管理Google相关依赖版本,避免后续出现版本冲突:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-sheets</artifactId>
            <version>v4-rev20240526-2.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

升级后,Sheets API的版本校验逻辑会正确识别2.x版本的google-api-client,同时两者的API兼容性也能得到保证。

内容的提问来源于stack exchange,提问作者Stan Ostrovskii

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 18:02:36