有注释问题在Kotlin中不起作用吗?
@Column(unique=true, nullable = false)
@Size(min = 1, max = 50)
var name: String = "",
@Size(max = 100)
var description: String = ""
我可以将空字符串保存到数据库中,并且唯一约束也无法通过注释起作用。有人之前有类似的问题吗?好心提醒 :)
最佳答案
使用Kotlin时,您需要在getter方法上应用约束验证器。这应该工作:
@Column(unique=true, nullable = false)
@get: Size(min = 1, max = 50)
var name: String = "",
@get: Size(max = 100)
var description: String = ""
关于spring-boot - Spring 注释在Kotlin中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38911714/