1. 程式人生 > >Mybatis異常-java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBE

Mybatis異常-java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBE

執行環境

SpringBoot

Mybatis異常摘要

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBER

Mybatis異常詳細

2016-01-11-10-45 [pool-2
-thread-1] [org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler] [ERROR] - Unexpected error occurred in scheduled task. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum
constant org.apache.ibatis.type.JdbcType.NUMBER at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365) at com.sun.proxy.$Proxy30.insert(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:237
) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40) at com.sun.proxy.$Proxy51.insertFailureRequestList(Unknown Source) at com.autonavi.service.impl.gaokuai.ExceptionHandleServiceImpl.insertFailureRequestList(ExceptionHandleServiceImpl.java:21) at com.autonavi.method.gaokuai.IssueUpload.action1(IssueUpload.java:92) at com.autonavi.task.ScheduledTasks.executeUploadTask(ScheduledTasks.java:56) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

異常產生原因

Caused by: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBER
        at org.apache.ibatis.builder.BaseBuilder.resolveJdbcType(BaseBuilder.java:67)
        at org.apache.ibatis.builder.SqlSourceBuilder$ParameterMappingTokenHandler.buildParameterMapping(SqlSourceBuilder.java:94)
        at org.apache.ibatis.builder.SqlSourceBuilder$ParameterMappingTokenHandler.handleToken(SqlSourceBuilder.java:73)
        at org.apache.ibatis.parsing.GenericTokenParser.parse(GenericTokenParser.java:47)
        at org.apache.ibatis.builder.SqlSourceBuilder.parse(SqlSourceBuilder.java:54)
        at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
        at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:241)
        at org.apache.ibatis.executor.statement.BaseStatementHandler.<init>(BaseStatementHandler.java:61)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.<init>(PreparedStatementHandler.java:36)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.<init>(RoutingStatementHandler.java:42)
        at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:348)
        at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43)
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
        ... 22 more
Caused by: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBER
        at java.lang.Enum.valueOf(Enum.java:238)
        at org.apache.ibatis.type.JdbcType.valueOf(JdbcType.java:21)
        at org.apache.ibatis.builder.BaseBuilder.resolveJdbcType(BaseBuilder.java:65)
        ... 42 more

異常排查

XML中是這樣寫的

<sql id="failureRequestValue">
        #{ID, jdbcType=NUMBER},
        #{CURRENT_DATE, jdbcType=VARCHAR},
        #{CURRENT_HOUR, jdbcType=NUMBER},
        #{CURRENT_MIN, jdbcType=NUMBER},
        #{ERROR_MESSAGE, jdbcType=VARCHAR}      
</sql>

但是查閱官方文件,發現Mybatis中jdbcType整形應該為NUMERIC,並沒有所謂的oracle中的整形NUMBER,所以這點應該記住。

<sql id="failureRequestValue">
        #{id, jdbcType=NUMERIC},
        #{current_date, jdbcType=VARCHAR},
        #{current_hour, jdbcType=NUMERIC},
        #{current_min, jdbcType=NUMERIC},
        #{error_message, jdbcType=VARCHAR}      
</sql>

上述錯誤導致的原因在於Mybatis的jdbcType型別沒有弄清楚,Mybatis中數值用NUMERIC,而不是oracle中的NUMBER。

相關推薦

Mybatis異常-java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBE

執行環境 SpringBoot Mybatis異常摘要 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Build

Mybatis——No enum constant org.apache.ibatis.type.JdbcType.XXX的解決辦法

該報錯基本上是JdbcType的引數不對,出錯的原因無非就是 沒有這種型別的引數 或者引數大小寫的問題這兩種 舉個例子 No enum constant org.apache.ibatis.type.JdbcType.INT的意思是mybatis

Mybatis錯誤:No enum constant org.apache.ibatis.type.JdbcType.number

No enum constant org.apache.ibatis.type.JdbcType.number 按照這個報錯的資訊,我的理解是:org.apache.ibatis.type.JdbcType中沒有number型別的常量。 好吧,應該是oracle中的型別常量numbe

Mybatis mapper層No enum constant org.apache.ibatis.type.JdbcType.date

在ibatis中,mapper層不需要關注這些引數而轉到mybatis後如果欄位值為空 必須設定jdbcType,如:insert into testTable (ID, NAME, DESCRIPTION, IMAGEURL, LINKUR

No enum constant org.apache.ibatis.type.JdbcType.Integer

public eof off 所有 alink keyword jdbc array IT public enum JdbcType { ARRAY(2003), BIT(-7), TINYINT(-6), SMALLINT(5), INTEG

springMVC報java.lang.IllegalArgumentException: No converter found for return value of type異常

問題描述:使用springMVC框架,用@responseBody返回物件的json資料,報出此異常。 部分程式碼: @ResponseBody public Result query(HttpServletRequest request, HttpServletResponse respons

170616、解決 java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList

pen group string image exception bean val 轉換 技術 報錯截圖: 原因:搭建項目的時候,springmvc默認是沒有對象轉換成json的轉換器的,需要手動添加jackson依賴。 解決步驟: 1、添加jackson依賴到pom

解決java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList這個問題

method posit adapt orm ask resp 運行 poi erro 今天使用SSM框架,用@ResponseBody註解,出現了這個問題 java.lang.IllegalArgumentException: No converter found f

java.lang.IllegalArgumentException: No converter found for return value of type: class com.smart.result.Page

lang spring cep 問題 ava 列表 convert 調用 val 今天學習了一下spring boot 中的mybatis,用mybatis來增刪改查用戶,獲取用戶,添加用戶,修改用戶,刪除用戶,修改用戶,都是可以的,但是獲取帶分頁的用戶列表,一直拋出這個j

解決java.lang.IllegalArgumentException: No converter found for return

一、背景   最近閒來無事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的環境(搭建步驟會在以後部落格中給出),結果執行程式時,適用@ResponseBody註解進行返回List<物件>的json資料時出現了:nested exception is

關於java.lang.IllegalArgumentException: No converter found for return value of type: class 的問題解決

1:此問題是responseBody返回的資料無法轉換成JSON格式資料 2:解決辦法 首先引入相關的jar包:         <dependency>     

Shiro異常java.lang.IllegalArgumentException: Odd number of characters的解決方案

java.lang.IllegalArgumentException: Odd number of characters. at org.apache.shiro.codec.Hex.decode(Hex.java:128) ~[shiro-core-1.3.2.jar:1.3.

java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Arr

java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList c錯誤 在搭建ssm的專案時出現了上面所說的錯誤,出現這個錯誤的原

Java異常 - java.lang.IllegalArgumentException: Could not resolve placeholder 'xxxx' in string value xx

異常描述 org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'xxx' defined in URL[file:/xxxx/xxx.xml

java.lang.IllegalArgumentException: No DataSource specified

 錯誤資訊如下: java.lang.IllegalArgumentException: No DataSource specified     at org.springframework.util.Assert.notNull(Assert.j

解決java.lang.IllegalArgumentException: No converter found for return value of type 的問題

controller返回一個dto,並且定義了@ResponseBody註解,表示希望將這個dto物件轉換為json字串返回給前端,但是執行時報錯:nested exception is java.lang.IllegalArgumentException: No converter found for re

java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.Has

今天使用了一個開源專案 是基於SpringMVC架構編寫的專案  發現在Controller里加入@ResponseBody註解之後 返回的型別轉換成JSON物件會出錯  控制檯裡反饋 org.springframework.web.util.Nested

Java反射異常:java.lang.IllegalArgumentException: wrong number of arguments

在用反射呼叫Hello.java的main方法時報了一個異常 java.lang.IllegalArgumentException: wrong number of arguments Hello.java package classloader; p

java.lang.IllegalArgumentException: No view found for id 0xad7b9d70 (unknown) for fragment, 爬坑

java.lang.IllegalArgumentException: No view found for id 0xad7b9d70 (unknown) for fragment, 爬出一個findViewById的坑 最近遇到一個比較奇怪且難定位的異常,是

另人抓狂的錯誤:java.lang.IllegalArgumentException: No property find found for type class

使用Spring data jpa時,建立自己的interface,並實現它,分別命名為: interface:ModuleDaoCustom implement:ModuleDaoCustomImpl 然後建立ModuleDao extends PagingAndSort