一、异常错误
ERROR 17084 --- [ main] o.s.boot.SpringApplication : Application run failed …… GetExperimentIdMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.TEXT ……
二、原因
数据库类型是 text类型,使用Mybatis 的 JdbcType也是 TEXT 类型,但 Mybatis 的 JdbcType类上没有这个类型,与text类型对应的应该是LONGVARCHAR类型,注意Mybatis严格区分大小写。
查看jdbcType枚举类源码
package org.apache.ibatis.type; import java.sql.Types; import java.util.HashMap; import java.util.Map; /** * @author Clinton Begin */ public enum JdbcType { ARRAY(Types.ARRAY), BIT(Types.BIT), TINYINT(Types.TINYINT), SMALLINT(Types.SMALLINT), INTEGER(Types.INTEGER), BIGINT(Types.BIGINT), FLOAT(Types.FLOAT), REAL(Types.REAL), DOUBLE(Types.DOUBLE), NUMERIC(Types.NUMERIC), DECIMAL(Types.DECIMAL), CHAR(Types.CHAR), VARCHAR(Types.VARCHAR), LONGVARCHAR(Types.LONGVARCHAR), DATE(Types.DATE), TIME(Types.TIME), TIMESTAMP(Types.TIMESTAMP), BINARY(Types.BINARY), VARBINARY(Types.VARBINARY), LONGVARBINARY(Types.LONGVARBINARY), NULL(Types.NULL), OTHER(Types.OTHER), BLOB(Types.BLOB), CLOB(Types.CLOB), BOOLEAN(Types.BOOLEAN), CURSOR(-10), // Oracle UNDEFINED(Integer.MIN_VALUE + 1000), NVARCHAR(Types.NVARCHAR), // JDK6 NCHAR(Types.NCHAR), // JDK6 NCLOB(Types.NCLOB), // JDK6 STRUCT(Types.STRUCT), JAVA_OBJECT(Types.JAVA_OBJECT), DISTINCT(Types.DISTINCT), REF(Types.REF), DATALINK(Types.DATALINK), ROWID(Types.ROWID), // JDK6 LONGNVARCHAR(Types.LONGNVARCHAR), // JDK6 SQLXML(Types.SQLXML), // JDK6 DATETIMEOFFSET(-155); // SQL Server 2008 }
三、解决方法
将jdbcType修改即可
jdbcType=LONGVARCHAR