我有一个带有模态类的多平台项目,用户。
User.kt
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.所做的尝试
FYI:我的build.gradle已经有了noArg,所以User.kt类是用一个无参数的公共构造函数编译的
发布于 2019-01-10 14:05:55
您的expect注释可能需要显式括号。
expect annotation class SharedImmutable()actual typealias SharedImmutable = kotlin.native.SharedImmutablehttps://stackoverflow.com/questions/54124454
复制相似问题