I've created a Kotlin gradle project using Spring IO.
Created a Controller
class with a method to return a String
.
When I build and run the project I'm getting 404 error. Looking at the logs I don't see the URL mapping to the method.
If I use Java instead of Kotlin it works fine. I am using JDK 10.
Code
@RestController
class IslandController
@GetMapping("/greeting")
fun getMessage() =
"hello world"
You have to include your function into the controller class:
@RestController
class IslandController {
@GetMapping("/greeting")
fun getMessage() = "hello world"
}