0

确保 getSqlMapClientTemplate() 生成工作对象的要求是什么?

我正在 Eclipse 上构建一个 Maven 项目,并编写 JUnit 测试。运行测试时,我在突出显示的行上遇到“未指定 SqlMapClient”错误:


@Override
public SignIn getpassforloginAttempt(String emailid, String token,
        int flag, String loginSrc, String ext_userId) {
    // TODO Auto-generated method stub
    SignIn signin = new SignIn();
    try {
        //Make a hashmap to store arguments
        HashMap params = new HashMap();
        params.put("EmailId", emailid);
        params.put("token", token);
        params.put("flag", flag);
        params.put("login_src", loginSrc);
        params.put("user_id_external", ext_userId);

        //SqlMapClientTemplate object used for data access via iBATIS SqlMapClient API
        //executes a mapped SQL insert statement
        template.insert("getpassforSignIn", params);

哪个使用这个对象:


public class SignInServiceImpl extends SqlMapClientDaoSupport implements
    SignInService {

    SqlMapClientTemplate template = getSqlMapClientTemplate();

鉴于此 bean , Spring应该处理其余部分:


<beans:bean id="sqlMapClient"
    class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
    <beans:property name="dataSource">
        <beans:ref local="dataSource" />
    </beans:property>
    <beans:property name="configLocation" value="classpath:sqlMapConfig.xml" />
</beans:bean>
<beans:bean id="userTestDao" class="com.pg.lms.dao.UserTestDao">
    <beans:property name="sqlMapClient" ref="sqlMapClient"></beans:property>
</beans:bean>

调用此资源路径文件:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig

PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" " http://www.ibatis.com/dtd/sql-map-config-2.dtd ">

<sqlMapConfig>

    <!-- USER_TABLE MAPPING WITH UserTable entity -->
    <sqlMap resource="login/SignUp.xml" />
    <sqlMap resource="login/SignIn.xml" />

    <sqlMap resource="course/AddCE.xml" />
    <sqlMap resource="course/MarketplaceCE.xml" />
    <sqlMap resource="course/modifyCe.xml" />
    <sqlMap resource="course/ViewCE.xml" />

    <sqlMap resource="accountprofile/Profile.xml" />
     <sqlMap resource="accountprofile/deleteaccount.xml" />

     <sqlMap resource="subscription/subscription.xml" />

    <sqlMap resource="pushnotifications/pushnotification.xml" />

    <sqlMap resource="promoevent/share.xml" />

    <sqlMap resource="emailtemplates/EmailTemplates.xml" />
</sqlMapConfig>

导致这个参数映射和过程(实际过程未显示):


<parameterMap class="java.util.Map" id="SignIn_attempt">
    <parameter property="EmailId" mode="IN" />
    <parameter property="pass" mode="OUT" />
    <parameter property="confirmed" mode="OUT" />
    <parameter property="flag" mode="IN" />
    <parameter property="token" mode="IN" />
    <parameter property="id" mode="OUT" />
    <parameter property="fname" mode="OUT" />
    <parameter property="lname" mode="OUT" />
    <parameter property="type" mode="OUT" />
    <parameter property="status" mode="OUT" />
    <parameter property="year" mode="OUT" />
    <parameter property="is_active" mode="OUT" />
    <parameter property="token2" mode="OUT" />
    <parameter property="login_src" mode="IN" />
    <parameter property="user_id_external" mode="IN" />
    <parameter property="useridExternal" mode="OUT" />
    <parameter property="loginSrc" mode="OUT" />
</parameterMap>


<procedure id="getpassforSignIn" parameterMap="SignIn_attempt">

    call
    login_SignIn_attempt(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

</procedure>

出了什么问题?以及如何解决这样的问题?

4

0 回答 0