If I have an interface with a generic type parameter as a bean, is it expected that Micronaut struggles to inject the right instance?
full context:
https://github.com/visionary-software-solutions/vitalizr-web/commit/46e6fb6b30219f840fa26aa73a606856d8b6be6b
Trying to run the BodyMassIndexControllerTest yields:
Unexpected error occurred: Failed to inject value for field [service] of class: visionary.software.vitalizr.web.bmi.BodyMassIndexController
Path Taken: BodyMassIndexController.service
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for field [service] of class: visionary.software.vitalizr.web.bmi.BodyMassIndexController
Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [visionary.software.vitalizr.web.bmi.$BodyMassIndexControllerTest$Service0Definition$Intercepted, visionary.software.vitalizr.web.weight.WeightService]
This seems to steer dangerously close to the Guice TypeLiteral mess because of Generic Type Erasure.
But I don't see anything like that mentioned in the IOC docs, and had hoped annotation processing would enable some tricks to avoid it.
Bug: I don't expect a VitalService<Weight> to match in the IOC context with a VitalService<BodyMassIndex> when trying to inject into the controllers
BodyMassIndexController is injected with only BMIService, WeightController with WeightService
Caused by: io.micronaut.context.exceptions.NonUniqueBeanException: Multiple possible bean candidates found: [visionary.software.vitalizr.web.bmi.$BodyMassIndexControllerTest$Service0Definition$Intercepted, visionary.software.vitalizr.web.weight.WeightService]
Been bitten by this too. @leadVisionary did you find any workaround for this?
Most helpful comment
Been bitten by this too. @leadVisionary did you find any workaround for this?