Add Spring boot with Rest controller
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "2.0.0"
|
||||
kotlin("plugin.spring") version "1.9.22"
|
||||
id("org.springframework.boot") version "3.1.0"
|
||||
id("io.spring.dependency-management") version "1.1.0"
|
||||
}
|
||||
|
||||
group = "org.example"
|
||||
@@ -10,6 +13,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation(kotlin("test"))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.example
|
||||
|
||||
fun main() {
|
||||
println("Hello World!")
|
||||
}
|
||||
11
src/main/kotlin/org/example/Application.kt
Normal file
11
src/main/kotlin/org/example/Application.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package org.example
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
|
||||
@SpringBootApplication
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<Application>(*args)
|
||||
}
|
||||
13
src/main/kotlin/org/example/HelloController.kt
Normal file
13
src/main/kotlin/org/example/HelloController.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.example
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
class HelloController {
|
||||
|
||||
@GetMapping("/hello")
|
||||
fun sayHello(): String {
|
||||
return "Hello, World!"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user