【发布时间】:2020-02-18 15:47:01
【问题描述】:
我正在开展一个小组项目,我们希望将后端部署到 Google Cloud。后端使用 Java11、Gradle 和 Spring-Boot 创建,并通过 GitHub 和 Travis 部署到 Google Cloud。
后端使用./gradlew bootrun 在本地主机上正常运行,但是在尝试将其部署到 Google Cloud 时,我们收到以下错误:
ERROR: (gcloud.app.deploy) Your application does not satisfy all of the requirements for a runtime of type [java11]. Please correct the errors and try again.
我们使用以下过程重新创建了此错误,从等式中删除了 GitHub 和 Travis:
使用以下设置在https://start.spring.io/ 创建了一个新的 Spring-Boot 项目:
- 项目:Gradle 项目
- 语言:Java
- Spring Boot:2.1.9
- 项目元数据:选项:Java:11
- 依赖项:Spring Security、Spring Web、GCP 支持
创建后,我们添加了文件app.yaml 和client_secret.json。
client_secret.json 文件包含有关 gcloud 中具有大量权限的测试客户端的信息。
app.yaml:
runtime: java11
env: flex
service: default
handlers:
- url: /.*
script: this field is required, but ignored
app.yaml 和 client_secret.json 都存储在同一位置 build.gradle 和 settings.gradle 是。
然后,从终端(我们在 VScode 中使用),我们运行gcloud app deploy。该命令首先询问我们是否要将后端部署到指定的谷歌云项目,列出它找到了app.yaml 文件、源和目标。然后,当我们按 Y 继续时,就会出现错误。
这是build.gradle 文件,可能有用(?):
plugins {
id 'org.springframework.boot' version '2.1.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "Greenwich.SR3")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
所以我们的问题是;错误是什么意思?我们如何解决它?我们已经尝试了很多东西,比如编辑app.yaml 和build.gradle,但似乎没有任何效果。我们也很难理解错误发生在哪里,因为后端在 localhost 上运行良好。
感谢您的每一个回复!
最好的问候 HaavardG :D
【问题讨论】:
-
查看 gcloud 上的
java11的 blog entry,它提到了一些关于entrypoint的内容,我在您发布的app.yaml文件中没有看到。你定义了这个变量吗? -
我认为你需要添加额外的依赖跳过 spotbugs 依赖,参考:gist.github.com/dineshbhagat/…
-
我相信您所说的
entrypoint是一个我命名为client_secret的 JSON 文件,其中包含有关 gcloud 中服务用户的信息。
标签: java spring-boot gradle google-cloud-platform java-11