【问题标题】:Gradle can not resolve appengineGradle 无法解析 appengine
【发布时间】:2019-08-15 05:21:13
【问题描述】:

我想在谷歌应用引擎上部署我的 spring 应用,但我收到了这个错误消息:

Execution failed for task ':appengineDeploy'.
> Deployment projectId must be defined or configured to read from system state
  1. Set appengine.deploy.projectId = 'my-project-id'
  2. Set appengine.deploy.projectId = 'GCLOUD_CONFIG' to use project from gcloud config.
  3. Using appengine.deploy.projectId = 'APPENGINE_CONFIG' has been deprecated.

我的笔记本电脑上已经安装了谷歌云 sdk 和应用引擎工具。

我在互联网上搜索,我发现我必须将项目 ID 放在 gradle 文件中:

appengine {
  deploy {
    projectId = "my-project-id"
  }
}

但问题是 gradle 无法解析所有这些属性。

我的 gradle 文件是否存在可能导致此问题的问题?

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
    dependencies {
        classpath("com.google.cloud.tools:appengine-gradle-plugin:2.1.0")
    }
}

plugins {
    id("org.springframework.boot") version "2.2.0.M4"
    id("io.spring.dependency-management") version "1.0.7.RELEASE"
    kotlin("jvm") version "1.3.31"
    kotlin("plugin.spring") version "1.3.31"
}

apply(plugin = "com.google.cloud.tools.appengine")

group = "com.demo.app"
version = "1.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
    maven { url = uri("https://repo.spring.io/snapshot") }
    maven { url = uri("https://repo.spring.io/milestone") }
}

extra["springCloudVersion"] = "Hoxton.M1"

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-server")
    implementation("org.springframework.boot:spring-boot-starter-web")

    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
        exclude(group = "junit", module = "junit")
    }
}

dependencyManagement {
    imports {
        mavenBom("org.springframework.cloud:spring-cloud- 
   dependencies:${property("springCloudVersion")}")
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

【问题讨论】:

    标签: spring google-app-engine google-cloud-platform gradle-kotlin-dsl


    【解决方案1】:

    在您的 SDK 中尝试setting your project,然后使用the below code

    appengine {
        deploy {
            projectId = "GCLOUD_CONFIG"
        }
    }
    

    【讨论】:

    • 感谢您的回答,但我已经配置了项目。我认为问题在于在 gradle 中添加应用程序引擎插件。我仍然不熟悉 kotlin gradle dsl,所以我认为我没有正确添加和应用插件.. 我尝试用 maven 部署一个项目,一切顺利
    • 我终于在post找到了解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-31
    相关资源
    最近更新 更多