How can specify the correct bean refrences, When I using Abstrarct factory method pattern with Spring.
I get constructor arguments errors on the Spring dispatcher-servlet.xml
.
the errors:
Ambiguous factory method argument types - did you specify the correct bean references as factory method arguments?
short dispatcher-servlet.xml
<bean id="myFactory" class="cwsei.spring.dao.CategoryFactory" factory-method="findCategory">
<constructor-arg type="java.lang.Enum" value="${categoryType}" />
</bean>
Here is my code:
public abstract class Category {
public abstract List list(int departId);
..
}
public class CategoryFactory {
public enum CategoryType { firstclass,secondClass,...}
public static Category findCategory(CategoryType categoryType) {
...
}
}
Thanks, mkohan
If your findCategory factory takes a given enum, then Spring does it all for you.
e.g
public class enum X { A, B }
public CategoryFactory findCategory( X someX )
now in Spring
<constructor-arg value="A" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With