Jasper Blues Jasper Blues - 3 months ago 14
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

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"))