I'm using kotlin. I have two spring classes, com.example.SpringConfigA and com.example.SpringConfigB. I am trying to import them into a com.example.SpringConfigParent, but none of the following works:
Try 1, error: This annotation is not repeatable
@Import(com.example.SpringConfigA)
@Import(com.example.SpringConfigB)
class SpringConfigParent {}
Try 2, error: Type mismatch: inferred type is () -> ??? but KClass<*> was expected
@Import({com.example.SpringConfigA, com.example.SpringConfigB})
class SpringConfigParent {}
Try 3, error: Only 'const val' can be used in constant expressions
@Import(arrayOf(com.example.SpringConfigA, com.example.SpringConfigB))
class SpringConfigParent {}    
What is the proper syntax in Kotlin for this?
EDIT: As @jaquelinep suggested, I forgot to add ::class, tries with that:
Try 1, error: This annotation is not repeatable
@Import(com.example.SpringConfigA::class)
@Import(com.example.SpringConfigB::class)
class SpringConfigParent {}
Try 2, error: Type mismatch: inferred type is () -> KClass<SpringConfigA> but KClass<*> was expected
@Import({com.example.SpringConfigA::class, com.example.SpringConfigB::class})
class SpringConfigParent {}
Try 3, error: Type inference failed. Expected type mismatch: inferred type is Array<KClass<out Any>> but KClass<*> was expected
@Import(arrayOf(com.example.SpringConfigA::class, com.example.SpringConfigB::class))
class SpringConfigParent {}    
                The syntax for multiple imports with one annotation is the following:
@Import(value = [Config1::class, Config2::class])
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With