java - Autowiring Map not working as expected -


i'm using spring 3.0.4. have beans use @autowired annotation on maps. these maps defined within application-context.xml file (as these maps constructed using several factory methods).

when use debugger, can see map gets constructed using (expected) bean id. however, once autowiring process starts, claims cannot find bean id has been created.

piece of code:

@autowired @qualifier("dienstverbandmap") private map<string, string> dienstverbandmap; 

piece of context xml:

<bean class="java.util.hashmap" id="dienstverbandmap" factory-bean="somefactorymethod" factory-method="getmappedmap"/>   

important detail, when change type java.lang.object in both class , context xml does wired in fact, can cast hashmap in code , work. not want obviously.

anyone got explantion i'm doing wrong?

i think type parameters dienstverbandmap. injection can performed safely if spring can figure out bean instance (a hashmap) instantiated hashmap<string, string>. spring losing type parameters because of bean's declared type raw type.

another possibility result signature of factory method wrong; e.g. map instead of hashmap, or raw hashmap rather hashmap<string, string>.

(some of these theories disproved if showed declaration of factory method.)


by way, according comments in spring-beans 2.0 dtd , 3.0 xsd, class attribute not used if supply factory-bean attribute. have tried leaving out entirely?


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -