Kotlin中的注释可以有不同的使用地点目标,如下所述:https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets
我的问题是:当没有明确定义use-site时,在类中注释属性时的默认目标是什么,如下例所示?
class Test {
@SomeAnnotation
var someProperty: String? = null
}
Run Code Online (Sandbox Code Playgroud)
背景
我正在尝试将Jongo作为Kotlin中的MongoDB客户端,并且在注释id字段时遇到问题.当它注释时,Jongo没有正确映射id属性:
@MongoId @MongoObjectId var id: String? = null
Run Code Online (Sandbox Code Playgroud)
有问题的注释只是杰克逊的元注释.但是,当我像这样注释属性时,它似乎工作,表明使用现场问题:
@field:[MongoId MongoObjectId]
var id: String? = null
Run Code Online (Sandbox Code Playgroud)
我希望这@field是默认的使用网站,但似乎不是.