【发布时间】:2017-03-24 21:03:08
【问题描述】:
我已经为 hashmap 编写了一个 xml 文件。
有两个问题,xml 文件显示一个红叉,但是当鼠标指针悬停在它上面或在“问题”部分时,都没有出现错误消息。
第二个问题是,它编译得很好,但是值键值不会传输到 hashmap 对象。类中的 HashMap 对象保持为“空”
哈希映射的 XML 是:
<bean id="GateKeeper" class="com.smarttrade.domain.GateKeeper"/>
<bean id="ClientToRateMap" class="java.util.HashMap">
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Integer">
<entry key="A" value=1 />
<entry key="B" value=2 />
<entry key="C" value=3 />
<entry key="D" value=4 />
</map>
</constructor-arg>
</bean>
类是
public class GateKeeper {
@Resource
@Qualifier("ClientToRateMap")
HashMap<String, Integer> ClientToRateMap;
public void ApplyRateLimitPerClient(ClientRequestEntity client) {
System.out.println(ClientToRateMap); // Ouput is NULL
}
}
【问题讨论】:
标签: java xml spring spring-boot hashmap