I am trying to define EnumMap in Spring with. I tried the following options
<util:map map-class="java.util.EnumMap" key-type="xyz.EnumType"> <entry key="SOME_ENUM_TYPE"> <ref bean="someBean"/> </entry> </util:map>
I get the following error
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.<init>()
The following definition is what I tried first
<util:map map-class="java.util.EnumMap"> <entry key="SOME_ENUM_TYPE"> <ref bean="someBean"/> </entry> </util:map>
and this gave me some error due to the inability to assign enumtype to String.
There are examples of using a shared map on the site, but I'm trying to check if I can use EnumMap, since it is considered the most optimal for Enums. The answer can be very obvious, so my apologies if the question is stupid. This is probably due to my limited knowledge of Spring. Thanks
Seagull
source share