1

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"
4

1 回答 1

6

您必须将您的功能包含到控制器类中:

@RestController
class IslandController {

    @GetMapping("/greeting")
    fun getMessage() = "hello world"
}
于 2018-06-26T10:27:41.110 回答