确保getSqlMapClientTemplate()产生工作对象有哪些要求?
我正在eclipse上构建一个maven项目,并编写JUnit测试。运行测试后,我在突出显示的行上遇到“No SqlMapClient specified”错误:
@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();
Spring should handle the rest给出了这个bean:
<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” &GT;
<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>
导致此参数Map和过程(实际过程未显示):
<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>
出了什么问题?如何解决这样的问题呢?