Spring Cloud Hoxton.SR6项目集成Firebase推送通知找不到依赖咨询
解决Firebase Admin依赖未找到问题
根因梳理
- Spring Boot与Spring Cloud版本不兼容:Hoxton.SR6版本Spring Cloud仅适配Spring Boot 2.3.x版本,你当前使用的2.5.5版本Spring Boot需要对应2020.0.x(代号Ilford)及以上版本的Spring Cloud,版本错配会导致依赖传递拉取异常,间接影响第三方依赖的识别。
- 部分国内Maven镜像源未同步google相关依赖包,拉取请求被拦截
- 本地Maven缓存损坏,导致已拉取的依赖识别失败
- AWS starter依赖和Firebase Admin的传递依赖(如guava)版本冲突,导致依赖树解析失败
解决步骤
- 修正版本适配关系,二选一即可:
- 方案1:将Spring Boot父版本降级为
2.3.1.RELEASE,匹配Hoxton.SR6的适配要求 - 方案2:将Spring Cloud版本升级为
2020.0.3,匹配Spring Boot 2.5.5的适配要求
- 方案1:将Spring Boot父版本降级为
- 检查Maven配置,如果使用国内镜像源,在
settings.xml或项目pom.xml中添加中央库兜底配置,确保可以拉取google的包 - 清理本地Maven缓存:删除本地仓库中
com/google/firebase目录,执行mvn clean install -U强制刷新依赖 - 若存在依赖冲突,显式指定Firebase Admin版本并排除冲突依赖,示例配置如下:
<dependency> <groupId>com.google.firebase</groupId> <artifactId>firebase-admin</artifactId> <version>9.2.0</version> <exclusions> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </exclusion> </exclusions> </dependency> <!-- 显式指定统一guava版本,避免和AWS starter冲突 --> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>31.1-jre</version> </dependency>
- 若部署环境为AWS内网,确认网络策略允许访问Maven中央库,或在企业私有仓库中添加firebase-admin的镜像同步配置
内容的提问来源于stack exchange,提问作者Prakash Adhikari
相关产品推荐
相关产品推荐

