我有一个带有模态类的多平台项目,用户。
使用户
class User {
val id = -1
val username = ""
val age = -1
val nickname = ""
}
我也有预期和实际的注释
annotation.kt[公共模块]
expect annotation class NodeEntity
expect annotation class Id
expect annotation class GeneratedValue
更重要的是,我有他们的实际实施
annotation.kt[jvm模块]
actual typealias ValueFor = org.neo4j.ogm.annotation.ValueFor
actual typealias NodeEntity = org.neo4j.ogm.annotation.NodeEntity
actual typealias Id = org.neo4j.ogm.annotation.Id
actual typealias GeneratedValue = org.neo4j.ogm.annotation.GeneratedValue
actual typealias Relationship = org.neo4j.ogm.annotation.Relationship
然后我回去注释我的user.kt
@NodeEntity
class User {
@Id
@GeneratedValue
val id = -1
val username = ""
val age = -1
val nickname = ""
}
但是当我编译它时,我得到了这个错误
Task :compileKotlinJvm FAILED
e: ...User.kt: (13, 2): This class does not have a constructor
e: ...User.kt: (21, 6): This class does not have a constructor
e: ...User.kt: (22, 6): This class does not have a constructor
我做错什么了?
N:B.尝试过
-
使预期的批注具有构造函数[无成功]
-
使所需的批注与构造函数匹配[错误:参数'{0}'在所需批注和实际批注中有冲突的值]
仅供参考:我的build.gradle已经有了noarg,因此user.kt类是用无参数公共构造函数编译的