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

Google My Business V4 API读取评论的Maven依赖及初始化问题

解决Google My Business V4评论API Maven依赖缺失问题

问题根源

你碰到的Missing artifact com.google.apis:google-api-services-mybusiness:jar:v4-rev20211101-1.32.1错误,核心原因是默认Maven中央仓库未收录该特定版本的依赖,或者项目未配置Google官方的Maven仓库源。

分步解决方案

1. 配置Google官方Maven仓库

Google的大部分API依赖托管在自家专属仓库,需在pom.xml中添加仓库配置:

<repositories>
    <repository>
        <id>google-maven-repo</id>
        <url>https://maven.google.com</url>
    </repository>
</repositories>

2. 更新依赖版本(若仓库配置后仍报错)

你使用的v4-rev20211101-1.32.1版本可能已停止公开分发,建议替换为同分支的最新兼容版本,比如v4-rev20240209-2.0.0,更新后的依赖片段:

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-mybusiness</artifactId>
    <version>v4-rev20240209-2.0.0</version>
</dependency>

3. 确保客户端初始化逻辑正确

依赖正常后,需确认MyBusiness客户端的初始化代码包含正确的认证逻辑,示例如下:

// 加载服务账号密钥文件
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("your-service-account-key.json"))
        .createScoped(Collections.singleton(MyBusinessScopes.MYBUSINESS));

// 构建API客户端
MyBusiness mybusiness = new MyBusiness.Builder(
        GoogleNetHttpTransport.newTrustedTransport(),
        JacksonFactory.getDefaultInstance(),
        credential)
        .setApplicationName("Your-Application-Name")
        .build();

// 调用评论接口
MyBusiness.Accounts.Locations.Reviews.Get myReview = mybusiness.accounts().locations().reviews().get(reviewName);
Review response = myReview.execute();

4. 手动安装依赖(极端场景)

如果上述方法均无效,可从Google Maven仓库手动下载对应jar包,再安装到本地Maven仓库:

mvn install:install-file -Dfile=google-api-services-mybusiness-v4-rev20211101-1.32.1.jar -DgroupId=com.google.apis -DartifactId=google-api-services-mybusiness -Dversion=v4-rev20211101-1.32.1 -Dpackaging=jar

内容的提问来源于stack exchange,提问作者Shila Mosammami

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 16:05:16