Why does @Primary sometimes fail for Kotlin classes?

I have the strangest problem.

I have a Java class A

and I also have a Kotlin class KA

that extends A

, both are @Component

s are KA

also annotated with @Primary

.

Some components KA

are auto-connect, others A

. This is actually even weirder, because for the same dependent bean between different launches of applications sometimes KA

gets autowired, sometimes A

.

If I rewrite KA

in Java then everything works as expected. Name of the attribute name / designer in all the dependent classes of the same: @Autowired A a;

.

It also doesn't matter if my Kotlin implementation implements a generic interface or extends the base class.

All Kotlin and Java classes live in src/main/java

.

Kotlin version 1.1.2-5

, I am using jvm8.

+3


source to share





All Articles