MST

星途 面试题库

面试题:Kotlin与Spring Boot集成中的依赖管理

在Kotlin与Spring Boot集成项目中,如何通过Gradle或Maven进行依赖管理?请举例说明添加Spring Web依赖以及Kotlin相关运行时依赖的配置方式。
14.0万 热度难度
编程语言Kotlin

知识考点

AI 面试

面试题答案

一键面试

使用Gradle进行依赖管理

  1. 添加Spring Web依赖: 在build.gradle.kts文件中添加如下依赖:
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-web")
}
  1. 添加Kotlin相关运行时依赖
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-kotlin")
    runtimeOnly("org.jetbrains.kotlin:kotlin-runtime")
}

使用Maven进行依赖管理

  1. 添加Spring Web依赖: 在pom.xml文件的<dependencies>标签内添加:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  1. 添加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>