【发布时间】:2023-03-06 13:16:01
【问题描述】:
Ktor.io的官方教程不行,我试过了。 这是我的第一次部署。感谢您的帮助。
我的 gradle 文件(kts):
import com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlExtension
buildscript {
dependencies {
classpath("com.google.cloud.tools:appengine-gradle-plugin:2.2.0")
}
}
apply {
plugin("com.google.cloud.tools.appengine")
}
plugins {
// Support for Kotlin
id("org.jetbrains.kotlin.jvm") version "1.3.61"
// Support for building a CLI application
application
// Documentation
id("org.jetbrains.dokka") version "0.10.1"
war
// id("com.improve_future.harmonica") version "1.1.24"
}
application {
mainClassName = "com.easythings.parkkometr.AppKt"
group = "com.easythings"
version = "0.0.1"
}
sourceSets {
main {
java.srcDir("app/main/src")
resources.srcDir("app/main/resources")
}
test {
java.srcDir("app/test/src/")
resources.srcDir("app/test/resources/")
}
}
repositories {
jcenter()
maven { setUrl("https://kotlin.bintray.com/ktor") }
}
dependencies {
val ktorVersion: String by project
val logbackVersion: String by project
val exposedVersion: String by project
val pgVersion: String by project
val spekVersion: String by project
val sendGridVersion: String by project
val assertJVersion: String by project
// Kotlin ============================================================================
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
// Libs ============================================================================
// Ktor - framework
implementation("io.ktor", "ktor-server-jetty", ktorVersion)
implementation("io.ktor", "ktor-server-core", ktorVersion)
implementation("io.ktor", "ktor-server-host-common", ktorVersion)
implementation("io.ktor", "ktor-auth", ktorVersion)
implementation("io.ktor", "ktor-auth-jwt", ktorVersion)
implementation("io.ktor", "ktor-gson", ktorVersion)
implementation("io.ktor", "ktor-network-tls-certificates", ktorVersion)
// Logback - application logger
implementation("ch.qos.logback", "logback-classic", logbackVersion)
// Exposed - orm
implementation("org.jetbrains.exposed", "exposed-core", exposedVersion)
implementation("org.jetbrains.exposed", "exposed-dao", exposedVersion)
implementation("org.jetbrains.exposed", "exposed-jdbc", exposedVersion)
implementation("org.jetbrains.exposed", "exposed-jodatime", exposedVersion)
// Postgresql - database driver
implementation("org.postgresql", "postgresql", pgVersion)
// SendGrid - mailer
implementation("com.sendgrid", "sendgrid-java", sendGridVersion)
// Deploy ============================================================================
providedCompile("com.google.appengine", "appengine", "1.9.60")
// Tests ============================================================================
}
tasks {
dokka {
outputDirectory = "$buildDir/docs/dokka"
outputFormat = "html"
}
test {
useJUnitPlatform {
includeEngines("spek2")
}
}
}
configure<AppEngineAppYamlExtension> {
deploy {
setAppEngineDirectory(".")
version = "1"
projectId = "XYZ-placeholder"
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
stage {
setAppEngineDirectory(".")
}
}
我的 app.yaml 文件:
runtime: java
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
我收到部署已成功完成的信息,但是当我调用 gcloud app browse 时收到 403 错误。
HTTP ERROR 403 访问 / 时出现问题。原因:
Forbidden
我认为我的应用程序没有启动,这是来自 Jetty 的错误,但我不知道如何检查/确认和修复它。
任务appengineRun在这个版本的GAE中不存在。
【问题讨论】:
标签: google-app-engine deployment ktor