【发布时间】:2018-10-16 17:19:37
【问题描述】:
我正在使用带有 Kotlin 的 Spring 数据休息,如果我使用数据类,则通过 uri 的关联将停止工作,并出现错误 no String-argument constructor/factory method to deserialize from String value
数据类
@Entity
data class Comment(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0,
var author: String? = null,
var content: String? = null,
@ManyToOne
var post: Post? = null) {
}
如果我使用简单的类,则关联工作正常。
@Entity
class Comment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long = 0
var author: String? = null
var content: String? = null
@ManyToOne
var post: Post? = null
}
关联是通过 POST 请求 {"author":"John Doe","content":"Dummy Content", "post":"http://localhost:8080/post/33"} 完成的
知道为什么我在使用数据类时会出现此错误,我该怎么做才能通过 uri 使用关联创建并继续使用数据类?
【问题讨论】:
标签: spring-boot kotlin spring-data-rest