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
java spring kotlin


source to share


No one has answered this question yet

Check out similar questions:

1722
Why is this code using random lines to print "hello world"?
1338
Why does Java have transient fields?
1249
How does the Java loop for each loop work?
633
Difference between <context: annotation-config> vs <context: component-scan>
559
Is there a destructor for Java?
93
Autowiring two beans implementing the same interface - how to set the default bean for auto-device?
6
Null Pointer Exception in Spring Proxy Class and Kotlin
3
Spring @Qualifier doesn't work without @Primary
0
How to translate Java class into Kotlin data class
0
(Java + Kotlin) Autowiring: At least 1 bit expected, which qualifies as an auto-connect candidate for this dependency



All Articles
Loading...
X
Show
Funny
Dev
Pics