kotlin springboot热部署
build gradle file
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.1.4"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
runtimeOnly("com.mysql:mysql-connector-j")
testImplementation("org.springframework.boot:spring-boot-starter-test")
runtimeOnly("org.springframework.boot:spring-boot-devtools")
}
tasks.withType {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
tasks.withType {
useJUnitPlatform()
}
Work with Spring Boot Devtools trigger file is supported. It is possible to enable trigger file and trigger application restart via an update action. New option is available in Edit Run/Debug configurations dialog for Spring Boot configurations. In order to enable it select a policy in 'On 'Update' action' combobox. Then 'Update Running Application' action will be available in Run/Debug tool window and in Run menu.
Work with Spring Boot Devtools trigger file is supported. It is possible to enable trigger file and trigger application restart via an update action. New option is available in Edit Run/Debug configurations dialog for Spring Boot configurations. In order to enable it select a policy in 'On 'Update' action' combobox. Then 'Update Running Application' action will be available in Run/Debug tool window and in Run menu.
The following policies are available:
Update resources
Update action performs resource update.
Update classes and resources.
Update action performs build.
Update trigger file
On application startup trigger file name is specified via VM options, update action triggers an application restart by touching trigger file.
Hot swap classes and update trigger file if failed
On application startup trigger file name is specified via VM options, update action performs build and hot swap. If hot swap is failed an application restart would be triggered by touching trigger file.
配置IDEA
当我们修改了类文件后,idea不会自动编译,得修改idea设置。 (1)File-Settings-Compiler-Build Project automatically (2)ctrl + shift + alt + / ,选择Registry,勾上 Compiler autoMake allow when app running


Comments