如何将DecoratingStringHashMapper与kotlin一起使用?

时间:2017-09-08 13:44:25

标签: kotlin

使用spring data keyvalue示例时,代码如下:

private final HashMapper<Post, String, String> postMapper =
   new DecoratingStringHashMapper<Post>(
        new JacksonHashMapper<Post>(Post.class));

我使用kotlin在线工具,它转换为:

private val postMapper = DecoratingStringHashMapper<Post>(
JacksonHashMapper<Post>(Post::class.java))

但是想法告诉我:

  

错误:(28,5)Kotlin:类型不匹配:推断类型是   JacksonHashMapper但是HashMapper!预计

该怎么办?

1 个答案:

答案 0 :(得分:0)

好消息,kotlin并不需要输入,只需使用这样:

  private val postMapper = 
       DecoratingStringHashMapper(Jackson2HashMapper(true))
希望得到它的帮助!