Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Kotlin Example of Class and Controller
data class Greeting(val id: Long, val content: String)
Next, a GreetingController will be used for a get request:
class GreetingController {
val counter = AtomicLong()
fun greeting(@RequestParam(value = "name", defaultValue = "World") name: String) =
Greeting(counter.incrementAndGet(), "Hello, $name")
When creating the Application class Spring Boot looks for a public static main method. This can be defined in Kotlin using a top-level function defined outside Application class like this:
class Application
fun main(args: Array<String>) {, *args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment