tinkertime
tinkertime

Reputation: 3042

Spring map definition

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?

Upvotes: 0

Views: 1792

Answers (1)

skaffman
skaffman

Reputation: 403501

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".

Upvotes: 5

Related Questions