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

使用Gradle构建AWS Lambda的Spring Cloud Function时遇插件找不到问题

在AWS Lambda构建Spring Cloud Function项目时的插件找不到问题

我尝试在AWS Lambda上运行Spring Cloud Function,遵循官方示例,使用gradlew build命令构建项目,但遇到如下错误:

  • What went wrong:
    Plugin [id: 'org.springframework.cloud.function.aws-lambda.packaging', version: '1.0.0'] was not found in any of the following sources:
  • Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
  • Plugin Repositories (could not resolve plugin artifact 'org.springframework.cloud.function.aws-lambda.packaging:org.springframework.cloud.function.aws-lambda.packaging.gradle.plugin:1.0.0')
    Searched in the following repositories:
    MavenLocal(file:/C:/Users/a1501/.m2/repository/)
    maven(https://repo.spring.io/milestone)
    Gradle Central Plugin Repository
  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 18s

解决方法
  1. 匹配插件与Spring Cloud Function版本
    1.0.0版本的aws-lambda.packaging插件未在公开仓库发布,需使用与Spring Cloud Function主版本一致的插件版本(如Spring Cloud Function 4.x对应插件版本4.x系列)。

  2. 添加正确的插件仓库
    在项目的settings.gradle(或settings.gradle.kts)中补充Spring官方插件仓库:

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven { url 'https://repo.spring.io/release' }
        maven { url 'https://repo.spring.io/milestone' }
    }
}

若使用Kotlin DSL,配置如下:

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("https://repo.spring.io/release")
        maven("https://repo.spring.io/milestone")
    }
}
  1. 修正插件引用配置
    在build.gradle中更新插件引用,使用正确的ID并通过Spring BOM统一管理版本:
plugins {
    id 'org.springframework.cloud.function' version '4.1.0'
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-function-dependencies:4.1.0"
    }
}
  1. 清理缓存重新构建
    执行以下命令清理本地Gradle缓存,刷新依赖后重新构建:
./gradlew clean build --refresh-dependencies

内容的提问来源于stack exchange,提问作者suzy tony.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.27 09:05:28