XML:

<bean id="myBean" class="com.google.common.collect.HashMultimap">
  <constructor-arg index="0" value="200"/>
  <constructor-arg index="1" value="2"/>
</bean>

Is it correct? When I try to inject this bean in another like:

<property name="myBean" ref="myBean"/>

i received the error: Cannot apply property values to null instance

有帮助吗?

解决方案

try this

<bean id="myBean" factory-method="create" class="com.google.common.collect.HashMultimap">
    <constructor-arg index="0" value="200" />
    <constructor-arg index="1" value="2" />
</bean>

其他提示

HashMultimap does not have a public constructor, therefore it's neither a Bean nor a POJO.

Source: google collections - HashMultimap

Instances are created using the static factory methods, among them one with no arguments (create()), maybe you can use this?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top