If @ConstructorBinding
is used on a Kotlin data class without a dependency on kotlin-reflect
, the annotation isn't found and autowiring is attempted instead. This leads to a failure like this:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in ind.ericjturley.mcve.configurationproperties.PushServicesProperties1 required a bean of type 'ind.ericjturley.mcve.configurationproperties.PushServicesProperties1$SnsClient' that could not be found.
Action:
Consider defining a bean of type 'ind.ericjturley.mcve.configurationproperties.PushServicesProperties1$SnsClient' in your configuration.
Consider adding @ConstructorBinding to ind.ericjturley.mcve.configurationproperties.PushServicesProperties1 if you intended to use constructor-based configuration property binding.
The second action is wrong as the class is already annotated with @ConstructorBinding
. It would be nice to fail in a more helpful way, for example by detecting that it's a Kotlin class but kotlin-reflect
is missing.
With thanks to @ericjturley, the problem can be reproduced with https://github.com/ericjturley/mcve-configurationproperties.