剛交接到這個(gè)項(xiàng)目,也是初次使用Spring_boot框架疙描。
前工作人員工作經(jīng)歷不是太深诚隙,所以,這是我修改他所留下來的問題做一次總結(jié)
【】錯(cuò)誤一
2019-03-28 16:39:47.687 DEBUG 51096 --- [0.1-8808-exec-7] c.z.s.d.v.E.getChangerListByVersionid : ==> Preparing: SELECT * from( SELECT A .requireid, A .starttime, A .devendtime, A .publishtime, b.postname, b.postid, A .requirename, A .baname, A .tlname FROM require_info A, enum_post b WHERE A .postid::INTEGER = b.postid) ri WHERE ri.requireid ::INTEGER= ?
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='versionid', mode=IN, javaType=class java.lang.Integer, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
Caused by: org.apache.ibatis.type.TypeException: Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
修改部分主要有兩處:
(1)修改方案:
<select id="getChangerListByVersionid" parameterType="Integer" resultType="com.zte.saltportal.model.ChangerListBean">
由于入?yún)⑹荢tring類型起胰,而parameterType卻給了Integer類型》》正確寫法parameterType="String".
【】錯(cuò)誤二
Error setting non null for parameter #1 with JdbcType null . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
(2)修改方案:
?SELECT * from( SELECT A .requireid, A .starttime, A .devendtime, A .publishtime, b.postname, b.postid, A .requirename, A .baname, A .tlname FROM require_info A, enum_post b WHERE A .postid::INTEGER = b.postid) ri WHERE ri.requireid?::INTEGER= #{versionid}?
去掉::INTEGER類型轉(zhuǎn)換》》
正確寫法:將ri.requireid::INTEGER = #{versionid} 改成 ri.requireid = #{versionid}
(3)考慮versionid入?yún)⑹欠裎ㄒ痪糜郑晃ㄒ粚⒉樵兂黾衔籽樱訢ao中定義返回值:A:對(duì)象名稱
操作為:ChangerListBeangetChangerListByVersionid(String versionid);
改為L(zhǎng)ist<ChangerListBean> getChangerListByVersionid(String versionid);
同時(shí)可以考慮是否需要對(duì)入?yún)⒃O(shè)置(@Param("versionid")String versionid)地消;