Some problems encountered with Kotlin annotations

(1) kotlin an annotation argument must be a compile-time constant. This problem is very common, and most of the reasons for this situation are caused by the conflict between the kotlin syntax and the original Java usage.

For example, when you want to inject some properties:
This question is often
this problem is the "$" symbol, which will be recognized as part of the string, so you need to escape the "$" and change it to "\$project";

(2) I have also encountered this kind of situation. In Java annotations, {} is used to represent arrays, but in kotlin, {} is actually a closure. At this time, you have to change the way of writing: either arrayOf or [] is possible
insert image description here
:
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/aa642531/article/details/112131264