since Spring Boot version 2.0.0.M4 I have the following injection problem (can be reproduced by running the AutorwireBugTest in the attached sample project):
I have a Kotlin class Foo which has a primary constructor that expects a parameter of type Bar
@AggregateclassFoo(param: Bar)
The class also has a default constructor generated by the kotlin-noarg Gradle plugin because of the following configuration in build.gradle:
But the same test works in 2.0.0.RC2 because the default constructor is used instead of the primary constructor. Is this behavior intended? Is there a workaround to prevent Spring from picking the wrong constructor.
The problem originally occured when using AxonFramework (http://www.axonframework.org, version, 3.0.5) in combination with Spring Boot and Kotlin. Axon use the following code to load aggregates:
spring-projects-issues commentedSep 26, 2017
•
edited
Andreas Baumgart opened SPR-16012 and commented
Hi,
since Spring Boot version 2.0.0.M4 I have the following injection problem (can be reproduced by running the AutorwireBugTest in the attached sample project):
I have a Kotlin class
Foo
which has a primary constructor that expects a parameter of typeBar
The class also has a default constructor generated by the kotlin-noarg Gradle plugin because of the following configuration in build.gradle:
noArg { annotation("com.example.autowirebug.Aggregate") }
Bar
is not a Spring bean i.e. autowiring the primary constructor fails in Spring 2.0.0.RC4 :But the same test works in 2.0.0.RC2 because the default constructor is used instead of the primary constructor. Is this behavior intended? Is there a workaround to prevent Spring from picking the wrong constructor.
The problem originally occured when using AxonFramework (http://www.axonframework.org, version, 3.0.5) in combination with Spring Boot and Kotlin. Axon use the following code to load aggregates:
which now fails with the error described above.
For me it's major problem because it prevents me from using Axon with the latest Spring Boot version and I don't know any workaround.
Thanks and regards,
Andreas
Affects: 5.0 RC4
Attachments:
Issue Links:
Referenced from: commits fb09a75
The text was updated successfully, but these errors were encountered: