我正在尝试使用 java bean 注入。它是一个非常基本的实现,但是注入不起作用。你能指导我吗?
测试.java
public class TempClass{
@Autowired
HashMap<String,HashMap<String,String>> newMap = new HashMap<String,HashMap<String,String>>();
public void setNewMap(HashMap<String, HashMap<String,String>> newMap)
{
newMap= newMap;
}
public HashMap<String, HashMap<String,String>> getNewMap()
{
return newMap;
}
}
另外:对于我的 bean config conn.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<util:map id="xyz" map-class="java.util.HashMap">
<entry key="x" value-ref="x" />
<entry key="y" value-ref="y" />
<entry key="z" value-ref="z" />
</util:map>
<util:map id="x" map-class="java.util.HashMap">
<entry key="xx" value="xx" />
<entry key="xy" value="xy" />
<entry key="xz" value="xz" />
</util:map>
<util:map id="y" map-class="java.util.HashMap">
<entry key="yx" value="yx" />
<entry key="yy" value="yy" />
<entry key="yz" value="yz" />
</util:map>
<util:map id="z" map-class="java.util.HashMap">
<entry key="zx" value="zx" />
<entry key="zy" value="zy" />
<entry key="zz" value="zz" />
</util:map>
<bean id="bean123" class="reference.to.class" autowire="byName">
<property name="newMap" ref="xyz" />
</bean>
</beans>
有人可以指导我什么是错的吗?