Spring Related-- @Autowired with Map<String, myObjectType> is not initialized in the IoC container
hisham ragheb
Ranch Hand
Joined: Apr 14, 2008
Posts: 30
posted
0
hi,
i created a Person bean which has a private field named degrees of type Map<String,Degree> and annotated it with @Autowired
i have also 2 classes who are different implementations of the Degree class, i defined and initialized them in the beans.xml
the problem arise when i try to get this field using its getter method where i always gets null. This mean this Map<String,Degree> is not initialized with the target beans
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
hisham ragheb
Ranch Hand
Joined: Apr 14, 2008
Posts: 30
posted
0
Kengkaj Sathianpantarit wrote:You should have a Map bean specified.
The problem that @Autowire somtimes works and most time it dont when its used with collections(List,Set Map)..the container dont create the collection and inject the beans by type in it
this is my problem...the collection returned sometimes is null other times contains the injected beans
I dont know why
Hong Anderson
Ranch Hand
Joined: Jul 05, 2005
Posts: 1936
posted
0
Please post your configuration.
hisham ragheb
Ranch Hand
Joined: Apr 14, 2008
Posts: 30
posted
0
Kengkaj Sathianpantarit wrote:Please post your configuration.
ok..but becareful that naming may not make so much sense here