Reputation: 991
I have a map in my spring xml defined as follows
<!-- Home Screen Backrgound Image Service -->
<bean id="homeScreenBackgroundImageService" class="com.services.images.impl.HomeScreenBackgroundImageServiceImpl" parent="imageServicesParent">
</bean>
<util:map id="imageServicesMap" value-type="com.services.images.ImageServicesParent">
<!-- Map between String key and List -->
<entry key="bean1" value-ref="homeScreenBackgroundImageService" />
When I inject this map into a class. My key is bean1 However, when this map is autowired homeScreenBackgroundImageService
I need to use autowiring to access this bean but how can I set it up so I can reference the beans in the map using the key bean1 as opposed homeScreenBackgroundImageService?
Unfortunately for my use case I need to use a map. I amn using Spring 4.1.4.RELEASE
Upvotes: 0
Views: 95
Reputation: 991
Sorry - found the answer nearly straight away - posting answer for completeness
Instead of autowiring like this
@Autowired
private ImageServicesParent imageServicesMap;
Use @resource instead and it will work
@Resource
private ImageServicesParent imageServicesMap;
Upvotes: 1