tags:

views:

52

answers:

1

What's the best way to create a bean for a HashMap<Class,String>?

Specifically, do I need to explicitly create a Class bean for the key or is the class name enough?

+4  A: 

If you mean a Map, where you don't mind which implementation, rather than specifically a HashMap, then use <util:map> (see section A.2.2.5 of the docs). That will likely create you something like a LinkedHashMap, which is probably good enough.

If you really want an actual HashMap, then you can specify the map-class attribute of <util:map> as "java.util.HashMap".

skaffman
`util:map` has a `map-class` attribute which does the same. Or do you mean that HashMap can't be created that way (I haven't tried)?
ChssPly76
oh, so it does, I didn't see that. Edited answer.
skaffman