Spring Util Map Annotation with Enum key


I wanted create java.util.Map in spring context xml file which injects the Map to one of my service class, but i was struggling with this because my Map's key is an enum value, Finally I was able fix that issue as following, in Spring we can specify the key-type and value-type specifically with generics values. That part was the interesting and new part i found time. All it goes as follows.


<map
     key-type="EnumType">
        <entry key="ENUM_VALUE"  value-ref="leastLoadedAssignmentMechanism" />
</map>




Comments

Popular posts from this blog

PostgreSQL bytea and oid

Adding MySQL datasource to JBOSS AS 7

Microservices Architecture with Spring Boot in 15mins