Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to inject TreeMap?

 
Kamil Kuchta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to inject TreeMap?
This map is fulfill in the application.
My beans

And setter in class House

Exception
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?

And what with generic data information Map<String, Dwarf>? Should bean contain this generic information?
 
Vivek K Singh
Ranch Hand
Posts: 85
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work, Try this:



And write the context as.



 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your setter method in the correct House class ? (pl.edu.agh.snowwhite.logic.House.java)
 
Kamil Kuchta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It turns out that I already had a getter getDwarfs() which returns a length of collection. When I changed bean name from dwarfs to dwarfsMap (and setter name setDwarfsMap) it started work. I think that that getter was a reason of my problems
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic