领先一步
VMware 提供培训和认证,助您加速进步。
了解更多我们很少为一个特性写博客,但考虑到 这个特性 是 Spring Cloud Function(一个相对年轻的项目)中最受欢迎的特性之一,我们认为有必要介绍一下,所以就有了这篇博客。
Spring Cloud Function 已初步支持 Kotlin lambda 表达式。这意味着 Spring Cloud Function 现在可以识别与 Java 的 Supplier、Function 或 Consumer **有效**匹配的 Kotlin lambda,并将它们视为这些 Java 接口。
也就是说
@Bean
open fun kotlinFunction(): (String) -> String {
return { it.toUpperCase() }
}
@Bean
open fun kotlinConsumer(): (String) -> Unit {
return { println(it) }
}
@Bean
open fun kotlinSupplier(): () -> String {
return { "Hello Kotlin" }
}
在此处 查看示例项目
就这些了。该特性在当前的快照版本中可用,并将成为 Spring Cloud Function 2.0.0.RELEASE 的一部分。这意味着增强和修改仍在进行中,因此您的反馈非常重要。
有关 Spring Cloud Function 的更多信息,请参阅以下内容:
https://springframework.org.cn/blog/2017/07/05/introducing-spring-cloud-function https://www.nurkiewicz.com/2018/04/sneak-peek-at-spring-cloud-function.html
祝您使用愉快!