0

org.springframework.beans.factory.BeanCreationExceptionResponseList Bean を使用しているため、Spring コントローラーを取得しています。

Error creating bean with name 'responseList' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: 1 constructor arguments specified but no matching constructor found in bean 'responseList' (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)

コンテキスト部分は次のとおりです。

<bean id="response" class="com.form.response.Response" scope="prototype"></bean>    
    <bean id="myController" class="com.controllers.MyController" scope="prototype">
            <property name="response" ref="response"></property>
            <property name="responseList" ref="responseList"></property>
    </bean>
    <bean id="responseList" class="carey.form.response.ResponseList">
            <constructor-arg type="java.util.List">
                <list>
                   <ref bean="response"/>
                </list>
            </constructor-arg>
    </bean>

これがビーンです:

package com.form.response;

import java.util.List;

public class ResponseList {

    public ResponseList() {
        // TODO Auto-generated constructor stub
    }

    private List<Response> responseList;

    public List<Response> getResponseList() {
        return responseList;
    }

    public void setResponseList(List<Response> responseList) {
        this.responseList = responseList;
    }

}

ここで欠けているものを誰か修正してもらえますか?

4

2 に答える 2

1

コンストラクター注入の使用

<bean id="response" class="com.form.response.Response" scope="prototype"></bean>    
    <bean id="myController" class="com.controllers.MyController" scope="prototype">
            <property name="response" ref="response"></property>
            <property name="responseList" ref="responseList"></property>
    </bean>
    <bean id="responseList" class="carey.form.response.ResponseList">
            <constructor-arg type="java.util.List">
                <list>
                   <ref bean="response"/>
                </list>
            </constructor-arg>
    </bean>

その後、豆のような

package com.form.response;

import java.util.List;

public class ResponseList {

    public ResponseList(List<Response> responseList) {
           this.responseList=responseList;
        // TODO Auto-generated constructor stub
    }

    private List<Response> responseList;

    public List<Response> getResponseList() {
        return responseList;
    }

    public void setResponseList(List<Response> responseList) {
        this.responseList = responseList;
    }

}

そしてセッター注入の場合

<bean id="response" class="com.form.response.Response" scope="prototype"></bean>    
    <bean id="myController" class="com.controllers.MyController" scope="prototype">
            <property name="response" ref="response"></property>
            <property name="responseList" ref="responseList"></property>
    </bean>
    <bean id="responseList" class="carey.form.response.ResponseList">
            <property type="java.util.List">
                <list>
                   <ref bean="response"/>
                </list>
            </property>
    </bean>

その後、豆のような

public class ResponseList {

    public ResponseList() {
    }

    private List<Response> responseList;

    public List<Response> getResponseList() {
        return responseList;
    }

    public void setResponseList(List<Response> responseList) {
        this.responseList = responseList;
    }

}
于 2014-02-03T06:14:44.107 に答える