gpt4 book ai didi

java - 如何在Kotlin中使用注释TypeDefs?

转载 作者:行者123 更新时间:2023-12-04 20:13:43 29 4
gpt4 key购买 nike

此Java代码段的等效Kotlin代码是什么?

@Data
@Entity
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "int-array", typeClass = IntArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class Parent implements Serializable {
//....
}

终于下面的代码工作了。
@TypeDefs(
TypeDef(name = "string-array", typeClass = StringArrayType::class),
TypeDef(name = "int-array", typeClass = IntArrayType::class),
TypeDef(name = "json", typeClass = JsonStringType::class),
TypeDef(name = "jsonb", typeClass = JsonBinaryType::class)
)

最佳答案

试试这个。

@Data
@Entity
@TypeDefs(
TypeDef(name = "string-array", typeClass = StringArrayType::class.java),
TypeDef(name = "int-array", typeClass = IntArrayType::class.java),
TypeDef(name = "json", typeClass = JsonStringType::class.java),
TypeDef(name = "jsonb", typeClass = JsonBinaryType::class.java))
class Parent : Serializable

关于java - 如何在Kotlin中使用注释TypeDefs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49875052/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com