I've defined a map in spring as such:
<util:map id="AdditionalParams" scope="prototype" map-class="java.util.HashMap"
key-type="java.lang.String" value-type="java.lang.String">
<entry key="Start" value="12345" />
<entry key="Finish" value="12365" />
</util:map>
And then I'm autowiring this bean to a property defined as:
private @Autowired @Qualifier(value = "AdditionalParams") Map<String, String> additionalParams;
When doing this, the an exception get's thrown saying that:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DutyCreator': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Map DutyCreator.additionalParams; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.lang.String] found for dependency [map with value type java.lang.String]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=AdditionalParams)}
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.lang.String] found for dependency [map with value type java.lang.String]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=AdditionalParams)}
Any ideas?
Cheers.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…