Beans Spring - comment câbler la valeur null comme un constructeur arg?

J'ai le texte suivant bean défini:

<bean id="myBean" class="com.me.myapp.Widget">
    <constructor-arg name="fizz" value="null"/>
    <constructor-arg name="buzz" ref="someOtherBean" />
</bean>

Quand je lance mon application, le Printemps lance un haricot config exception:

[java] Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myBean' defined in class path resource [spring-config.xml]:
Unsatisfied dependency expressed through constructor argument with index 0
of type [com.me.myapp.Widget]: Could not convert constructor argument value of
type [java.lang.String] to required type [com.me.myapp.Widget]: Failed to
convert value of type 'java.lang.String' to required type
'com.me.myapp.Widget'; nested exception is java.lang.IllegalStateException:
Cannot convert value of type [java.lang.String] to required
type [com.me.myapp.Widget]: no matching editors or conversion strategy found

Je veux juste créer un Widget comme je le ferais si j'ai écrit la suite de Java:

Widget w = new Widget(null, someOtherBean);

Comment puis-je faire cela? Merci à l'avance!

InformationsquelleAutor IAmYourFaja | 2012-10-17