Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Injecting a Map in enum through Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Injecting a Map in enum through Spring" Watch "Injecting a Map in enum through Spring" New topic

Injecting a Map in enum through Spring

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi All,

I have an Enum with few maps in it. Can I inject the maps through Spring? I am using Spring 2.5


Be Humble... Be Nice.
Bill Gorder

Joined: Mar 07, 2010
Posts: 1646

Enums are basically static, you cannot inject beans into them. I can think of a few hacks that might get a reference to a bean into an enum, but you can not inject it directly. You might wan't to think about the design of you application first though and see if there is a better way.

[How To Ask Questions][Read before you PM me]
I agree. Here's the link:
subject: Injecting a Map in enum through Spring
Similar Threads
semicolon in Enums
Variable with string as index or smt...
replace singleton with enum
hash code for enum and long field combined
Define enum as Spring Bean and dependency inject it into another Spring Bean