使用Gradle进行依赖管理
- 添加Spring Web依赖:
在
build.gradle.kts
文件中添加如下依赖:
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
}
- 添加Kotlin相关运行时依赖:
dependencies {
implementation("org.springframework.boot:spring-boot-starter-kotlin")
runtimeOnly("org.jetbrains.kotlin:kotlin-runtime")
}
使用Maven进行依赖管理
- 添加Spring Web依赖:
在
pom.xml
文件的<dependencies>
标签内添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- 添加Kotlin相关运行时依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
</dependency>