你好@stackoverflow 社区,
我有一个具有以下结构的 Kotlin Spring Boot 应用程序
.
├── build.gradle.kts
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── pipeline.yml
├── services
│ └── environment
│ ├── build.gradle.kts
│ └── src
│ └── main
│ └── kotlin
│ └── com
│ └── demo
│ └── app
│ └── services
│ └── environment
│ ├── controller
│ │ └── EnvironmentController.kt
│ ├── model
│ │ └── Environment.kt
│ └── repository
│ └── EnvironmentRepository.kt
├── settings.gradle.kts
└── web
├── build.gradle.kts
└── src
└── main
├── kotlin
│ └── com
│ └── demo
│ └── app
│ └── DemoApplication.kt
└── resources
└── application.properties
构建.gradle.kts
plugins {
id("org.springframework.boot") version "2.3.3.RELEASE" apply false
id("io.spring.dependency-management") version "1.0.10.RELEASE" apply false
kotlin("jvm") version "1.4.0" apply false
kotlin("plugin.spring") version "1.4.0" apply false
}
allprojects {
group = "com.demo"
version = "1.0.0-SNAPSHOT"
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "14"
}
}
}
subprojects {
repositories {
mavenCentral()
}
apply {
plugin("io.spring.dependency-management")
}
}
服务/环境/build.gradle.kts
plugins {
id("org.springframework.boot")
kotlin("jvm")
kotlin("plugin.spring")
application
}
dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.postgresql:postgresql")
}
application {
mainClassName = "com.demo.app.services.environment"
}
网页/build.gradle.kts
plugins {
id("org.springframework.boot")
id("com.google.cloud.tools.jib") version "2.5.0"
kotlin("jvm")
kotlin("plugin.spring")
application
}
dependencies {
implementation(project(":services:environment"))
implementation(kotlin("reflect"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
}
application {
mainClassName = "com.demo.app"
}
jib {
from {
image = "openjdk:14-jdk-slim"
}
to {
image = "demo/app"
}
}
不知何故,当我使用 jibDockerBuild 构建我的 docker 映像时,docker 容器内正在运行的应用程序中缺少子模块“services.environment”,我无法访问我在这个子模块中编写的 REST API。
...我真的被这个问题困住了,不能再进一步了,我希望能得到帮助。
谢谢, 安德里奥什