Spring REST、Kotin 和默认原始参数导致错误

Spring REST, Kotin and default primitive parameters leads to an error

我收到一个错误:

Optional long parameter 'count' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type

当我尝试调用此 REST 控制器时。

    @RequestMapping("/api/audio/tracks", produces = arrayOf(APPLICATION_JSON_VALUE))
    interface SomeApi {


        @RequestMapping(method = arrayOf(GET))
        fun list(@RequestParam("count", defaultValue = "10") count: Long): Any
    }

不spring看defaultValue吗?

如何解决此类问题?

!Kotlin 默认值也不起作用

我找到了适合我的情况的解决方案:

原因是因为一个接口。当我在实现中放置 @RequestParam("count", required = false, defaultValue = "10") 时,一切都开始工作。