java - Why does Spring report a factory method arg as ambiguous? -
i'm trying create bean:
<bean id="mybean" class="java.lang.string" factory-method="valueof"> <constructor-arg name="obj" value="a string" type="java.lang.object"/> </bean> i want spring use method java.lang.string#valueof(object obj) when creating bean.
i get:
caused by: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [char[]]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [char[]]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [boolean]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [long]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [char]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [double]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [float]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [int]: ambiguous factory method argument types - did specify correct bean references factory method arguments? related cause: org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean name 'mybean' defined in class path resource [meta-inf/test-contexts/testmanualdependencybundleresolvercontext.xml]: unsatisfied dependency expressed through constructor argument index 0 of type [java.lang.object]: ambiguous factory method argument types - did specify correct bean references factory method arguments? why? think i've specified needed spring resolve correct method want use.
simply remove name attribute, xsd docs name says:
only needed avoid ambiguities, e.g. in case of 2 arguments of exact same type. note: requires debug symbols stored in class file in order introspect argument names!
Comments
Post a Comment