方法context.getBean(名稱,用戶)的文件說,春參數傳遞到工廠方法在運行時
允許指定明確的構造函數的參數/工廠方法 參數
但無論我做什麼(嘗試所有),以最合理的設置,當豆子在初始化過程中加載時得到這個結果:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'fileValidator' defined in
PortletContext resource
[/WEB-INF/classes/context/customer-form-portlet.xml]: Unsatisfied
dependency expressed through constructor argument with index 0 of type
[com.liferay.portal.model.User]: Ambiguous factory method argument
types - did you specify the correct bean references as factory method
arguments?
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'fileValidator' defined in
PortletContext resource
[/WEB-INF/classes/context/customer-form-portlet.xml]: Unsatisfied
dependency expressed through constructor argument with index 0 of type
[com.liferay.portal.model.User]: Ambiguous factory method argument
types - did you specify the correct bean references as factory method
arguments?
<bean id="fileValidator"
class="cz.instance.transl.validation.file.FileValidator"
factory-method="createInstance" />
private FileValidator(User user) {
this.user = user;
}
public static FileValidator createInstance(User user) {
return new FileValidator(user);
}
評論說,你可以做到這一點,但如果你在bean的XML definiton或者未指定構造函數的參數,它失敗。
不幸的是,即使原型也是如此。使用3.1.0.M2 – lisak
@lisak:首先,停止使用beta版本,堅持穩定版本(例如3.0.x) – skaffman
它必須是3.1.0.M2中的錯誤...它非常複雜在那裏找到原因,如果我找到了,我會試着提高票價。謝謝 – lisak