I am moving my application to kotlin, and one of my files has an autowire map for the implementation of a strategy pattern. Spring falls to inject the beans when I change this file to kotlin
I have already tried lateinit, @jvmfield and others. I have been making changes and looking at the resulting decompilied java to see if its clear why there is an error. It look like its becuase the hashmap in the java version does not have show the type.
Hashmap vs HashMap<String,Object>
Java version before change. This gathered all beans of type AudienceService and injected them into this map
@Autowired
private Map<String, AudienceService> audienceServiceMap = new HashMap<>();
Kotlin version:
@Autowired
private lateinit var audienceServiceMap : HashMap<String, AudienceService>
Java decompiled version of the above kotlin code
@Autowired
private HashMap audienceServiceMap;
Error by spring
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'audienceContext': Unsatisfied dependency expressed through field 'audienceServiceMap'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.util.HashMap<java.lang.String,