Ich habe die folgende Bohne definiert:Spring Beans - wie NULL als Konstruktor arg verdrahten?
<bean id="myBean" class="com.me.myapp.Widget">
<constructor-arg name="fizz" value="null"/>
<constructor-arg name="buzz" ref="someOtherBean" />
</bean>
Wenn ich meine app laufen, wirft Frühling eine Bohne Config Ausnahme:
[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
Ich möchte nur ein Widget
wie ich würde erstellen, wenn ich das schrieb folgende Java:
Widget w = new Widget(null, someOtherBean);
Wie kann ich das tun? Danke im Voraus!