Jak wygląda sprawa wstrzykiwania np. obiektów klasy TreeMap?
Mapa jest wypełniana w aplikacji.
Mam beany
1. <bean id="dwarfs" class="java.util.TreeMap" />
2.
3. <bean id="house" class="pl.edu.agh.snowwhite.logic.House">
4. <property name="dwarfs" ref="dwarfs"></property>
5. </bean>
i mój setter
1. public void setDwarfs(Map<String, Dwarf> dwarfs){
2. this.dwarfs=dwarfs;
3. }
Niestety rzuca wyjątek
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'house' defined in file [snowWhiteBeans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dwarfs' of bean class [pl.edu.agh.snowwhite.logic.House]: Bean property 'dwarfs' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
A co z genericami przy wstrzykiwaniu. Np. Map<String, Dwarf>, powinno się zawrzeć tę informację w beanach?