Вопрос

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