Jasper Blues Jasper Blues - 1 year ago 123
Java Question

Using @EnableNeo4jRepositories(basePackageClasses = "myApp") in Kotlin

I've added the following annotation:

@EnableNeo4jRepositories(basePackages = "myApp")

Works fine in Java, but the Kotlin compiler gives:

(40, 51): Type mismatch: inferred type is kotlin.String but kotlin.Array<kotlin.reflect.KClass<*>> was expected

Answer Source

When an array is expected, Java will auto-box a single value into a singleton array. In Kotlin, you can use:

@EnableNeo4jRepositories(basePackages = arrayOf("myApp"))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download