第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

視頻不完整……另外插入可以,但是查詢修改刪除報(bào)錯(cuò),有人遇到一樣的錯(cuò)誤嗎?

同一個(gè)錯(cuò)誤,就講講查詢好了

controller里的映射代碼段:

@RequestMapping("/queryuser")

public User queryUser(String id) throws Exception{

return userService.queryUserById(id);?

}

serviceImpl的代碼段

@Transactional(propagation = Propagation.SUPPORTS)

public User queryUserById(String id) throws Exception{

?return userMapper.selectByPrimaryKey(id);

}

代碼這么簡(jiǎn)單了……怎么會(huì)出錯(cuò)的?錯(cuò)誤如下:

這是網(wǎng)頁的反饋:

{

? ? "timestamp": "2018-11-23T18:04:30.660+0000",

? ? "status": 500,

? ? "error": "Internal Server Error",

? ? "message": "nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='age', 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 #5 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",

? ? "path": "/mybatis/queryuser"

}

這是eclipse的錯(cuò)誤

org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='age', 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 #5 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] with root cause

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

這里在說age屬性的jdbcType是Integer,然后不能由String轉(zhuǎn)Integer,但是那個(gè)xxmapper.xml是自動(dòng)生成的,視頻里老師也沒改過,我用String的ID查出來User對(duì)象,不是應(yīng)該直接顯示成JSON嗎?為什么需要轉(zhuǎn)age屬性?百度了一下,發(fā)生這個(gè)錯(cuò)誤的原因各不相同,看到的朋友請(qǐng)賜教

正在回答

1 回答

哎,我傻了呀,解決了。我一開始思路不對(duì),我以為是jdbcType出了什么問題,想想userMapper.xml是自動(dòng)生成的不應(yīng)該呀,后來以為是我application.properties里的下面這兩句沒生效,導(dǎo)致什么類加載器沒用對(duì)產(chǎn)生了沖突

restart.include.mapper=/mapper-[\\w-\\.]+jar

restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar

然后我就注掉了devtools的依賴,但是還是不對(duì)。后來一行行看下面的錯(cuò)誤,發(fā)現(xiàn)還是service層的問題,最后才找到了……我的方法是return userMapper.selectByPrimaryKey(id);這個(gè)primaryKey數(shù)據(jù)庫里建表時(shí)候是指定了,但是自動(dòng)生成的實(shí)體類倒是干干凈凈的,它應(yīng)該是沒找到這個(gè)primaryKey,然后剛好匹配下來age是Integer類型,才跟我扯這個(gè)“java.lang.String cannot be cast to java.lang.Integer”和”Error setting non null for parameter #5 with JdbcType null . ”這點(diǎn)錯(cuò)誤卡了我一個(gè)晚上真是太傻了……話說自動(dòng)生成怎么不那么智能呢,主鍵不給實(shí)體類自動(dòng)指定掉


1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

視頻不完整……另外插入可以,但是查詢修改刪除報(bào)錯(cuò),有人遇到一樣的錯(cuò)誤嗎?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)