title: How to define an EnumMap in Spring 3.0
body: <p>I've been trying to define an EnumMap in Spring using  . I tried the following variations</p>
  
  <pre><code>&lt;util:map map-class="java.util.EnumMap" key-type="xyz.EnumType"&gt;
  &lt;entry key="SOME_ENUM_TYPE"&gt;
     &lt;ref bean="someBean"/&gt;
  &lt;/entry&gt;
  &lt;/util:map&gt;
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>Error creating bean with name 'util:map#1c599b0e': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.EnumMap]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.util.EnumMap.&lt;init&gt;()
  </code></pre>
  
  <p>The following definition is what I tried initially</p>
  
  <pre><code>&lt;util:map map-class="java.util.EnumMap"&gt;
  &lt;entry key="SOME_ENUM_TYPE"&gt;
     &lt;ref bean="someBean"/&gt;
  &lt;/entry&gt;
  &lt;/util:map&gt;
  </code></pre>
  
  <p>and this gave me some error of not being able to assign the enumtype to String.</p>
  
  <p>There are examples on the site to using a generic map, but I am trying to see whether I can use an EnumMap, since it's considered the most optimal for Enums. The answer might be very obvious, so my apologies if the question is stupid. This is probably due to my limited knowledge of Spring. Thanks</p>