作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个 Spring Boot 项目
Project1 (Spring boot project)
|
|--build.gradle
|--settings.gradle
|--src/main/kotlin
Project2 (Spring boot project)
|
|--build.gradle
|--settings.gradle
|--src/main/kotlin
最佳答案
根项目
作为第一步,您需要添加带有两个子项目的根项目。settings.gradle.kts
rootProject.name = "demo-root"
include(
"project1",
"project2"
)
build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
base
kotlin("jvm") version "1.3.71" apply true
id("java-library")
id("org.springframework.boot") version "2.2.6.RELEASE" apply false
id("io.spring.dependency-management") version "1.0.9.RELEASE" apply false
id("org.jetbrains.kotlin.plugin.jpa") version "1.3.71" apply false
kotlin("plugin.spring") version "1.3.71" apply false
}
allprojects {
group = "com.dempcompany"
version = "0.0.1-SNAPSHOT"
repositories {
mavenCentral()
}
// apply {
// plugin("kotlin")
// }
tasks.withType<JavaCompile> {
sourceCompatibility = "13"
targetCompatibility = "13"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "12"
}
}
}
subprojects {
// apply {
// plugin("io.spring.dependency-management")
// }
}
dependencies {
subprojects.forEach {
// Make the root project archives configuration depend on every subproject
archives(it)
}
}
项目1
project1/build.gradle.kts
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
base
kotlin("jvm") version "1.3.71" apply true
id("java-library")
id("org.springframework.boot") version "2.2.6.RELEASE" apply false
id("io.spring.dependency-management") version "1.0.9.RELEASE" apply false
id("org.jetbrains.kotlin.plugin.jpa") version "1.3.71" apply false
kotlin("plugin.spring") version "1.3.71" apply false
}
allprojects {
group = "com.democompany"
version = "0.0.1-SNAPSHOT"
repositories {
mavenCentral()
}
// apply {
// plugin("kotlin")
// }
tasks.withType<JavaCompile> {
sourceCompatibility = "13"
targetCompatibility = "13"
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "12"
}
}
}
subprojects {
// apply {
// plugin("io.spring.dependency-management")
// }
}
dependencies {
subprojects.forEach {
// Make the root project archives configuration depend on every subproject
archives(it)
}
}
project1/setting.gradle.kts
rootProject.name = "project1"
项目2
project2/build.gradle.kts
plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
kotlin("jvm")
kotlin("plugin.spring")
}
repositories {
mavenCentral()
maven("https://jitpack.io")
}
java.sourceCompatibility = JavaVersion.VERSION_13
dependencies {
/* Project modules */
implementation(project(":project1", "default"))
/* Spring Framework */
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
/* Kotlin */
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
}
project2/settings.gradle.kts
rootProject.name = "project2"
关于java - Gradle , Kotlin : How to add another spring boot project as a module dependency in intellij,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55197672/
我是一名优秀的程序员,十分优秀!