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

配置Google Cloud Document AI Java依赖时无法导入问题求助

解决Document AI Java客户端导入失败问题

问题根源

你的POM配置中,google-cloud-document-ai依赖被放在了<dependencyManagement>节点下,这个节点仅用于管理依赖版本,不会将依赖实际引入到项目中,导致IDE无法找到相关类,从而出现导入错误。

修正后的POM配置

将google-cloud-document-ai依赖从<dependencyManagement>移到独立的<dependencies>节点中(无需指定版本,因为BOM已统一管理版本):

<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <version>1</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>libraries-bom</artifactId>
                <version>26.1.3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- 实际引入Document AI依赖 -->
    <dependencies>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-document-ai</artifactId>
        </dependency>
    </dependencies>

</project>

后续验证步骤

  • 执行mvn clean install命令,刷新Maven依赖
  • 在IDE中执行重新加载Maven项目操作(通常是右键项目 → Maven → Reload Project)
  • 检查导入语句是否正常识别

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 00:38:18