I'm trying to use Spring and have a trouble using it for a case. I have the following code:
<util:map id="someMap" value-type="java.util.Set">
<entry key="a" value-ref="setA"/>
<entry key="b" value-ref="setB"/>
</util:map>
<util:set id="setA">
<value>A</value>
</util:set>
<util:set id="setB">
<value>B</value>
</util:set>
with the following Java code (using @Qualifier to get "someMap"):
package a.b.c;
public class SomeClass {
private final Map<String, Set<String>> someMap;
@Autowired
public SomeClass(@Qualifier("someMap") final Map<String, Set<String>> someMap) {
this.someMap = someMap;
}
}
and it's giving me the following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'a.b.c.SomeClass': Unsatisfied dependency expressed through constructor argument with index 2 of type [java.util.Map]: : No matching bean of type [java.util.Set] found for dependency [map with value type java.util.Set]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:{@org.springframework.beans.factory.annotation.Qualifier(value=someMap)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.util.Set] found for dependency [map with value type java.util.Set]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=someMap)}
Looks like it's having trouble finding the Set but I don't know why it's happening. How would you solve this problem?