Closed
Description
Manfred Quasten opened SPR-17197 and commented
bean definition:
<bean id="instances" class="java.util.HashMap" >
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.String">
<entry key="0001" value="Beschreibung " />
...
</map>
</constructor-arg>
</bean>
public InstanceRepositoryImpl {
@Autowired
InstanceRepositoryImpl(@Qualifier("instances") final Map<String,String> instances ) {
this.instances= instances;
}
}
Error Message:
No qualifying bean of type 'java.util.Map<java.lang.String, java.lang.String>' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=instances)}
When I change Map
to HashMap<String,String>
it works: no exception is thrown.
It should work using the Map
interface. The @Qualifier
annotation specifies the name; the bean exists.
Affects: 5.0.3
Issue Links:
- Accept empty Collection<Component> injection for single constructor scenarios [SPR-15338] #19901 Accept empty Collection injection for single constructor scenarios
- Ordered list access for BeanFactory.getBeanProvider(), superseding ObjectProvider<List> [SPR-17272] #21805 Ordered list access for BeanFactory.getBeanProvider(), superseding ObjectProvider