mybatis 插入的时候一句sql报错如下。

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."VARCHAR"

insert into sys_user(
<if test="userId != null and userId != '' ">user_id,</if> create_time
)values(
<if test="userId != null and userId != ''">#{userId,jdbcType="VARCHAR"},</if> sysdate
)

原因在于

#{userId,jdbcType="VARCHAR"}, 

即mybatis所定义的类型常量枚举不存在,mybatis 解析为了"VARCHAR" 带双引号的字符串,改为

insert into sys_user(
<if test="userId != null and userId != '' ">user_id,</if> create_time
)values(
<if test="userId != null and userId != ''">#{userId,jdbcType=VARCHAR},</if> sysdate
)

把双引号去掉或者直接不写jdbcType 即可。

mybatis: No enum constant org.apache.ibatis.type.JdbcType."VARCHAR"的更多相关文章

  1. 【myBatis】java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBE

    可能#{current_date, jdbcType=VARCHAR}中的VARCHAR类型不对

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

    同事今天在用mybatis查询时候,报了上面这个问题.上网查了下,原来是mybatis封装类型的问题.原因是在resultMap中jdbcType写为了Integer,但是在MyBatis中没有这个数 ...

  3. java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.Integer

    mybatis配置的jdbaType类型要是大写的,否则就会出现此种异常 原因是在xml中配置的 jdbcType中有小写字母

  4. No enum constant org.apache.ibatis.type.JdbcType.xxx 错误

    配置文件Mapper中JdbcType错误,有可能是大小写,有可能是拼写错误

  5. mybatis No enum const class org.apache.ibatis.type.JdbcType.Date 坑爹的配置

    转自:https://lihaiming.iteye.com/blog/2248059 在ibatis中不需要关注这些参数 而转到mybatis后 如果字段值为空 必须设置jdbcType如inser ...

  6. Mybatis异常--java.lang.IllegalArgumentException: NO ENUM const class org.apache.ibatis.type.JdbcType.int

    今天下午写代码时发现一直报错,找了半天都没找到错误原因. 最后才发现原来是XML配置错误,某条属性的JdbcType我按照以前ibatis的习惯写的int,但是Mybatis不识别的. 上Mybati ...

  7. mybatis No enum const class org.apache.ibatis.type.JdbcType.Integer

    mybatis报错:没有Integer这个类型的jdbcType值 原因:mybatis配置重的jdbaType类型要是大写的 如图所示:

  8. 【异常及源码分析】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping

    一.异常出现的场景 1)异常出现的SQL @Select("SELECT\n" + " id,discount_type ,min_charge, ${cardFee} ...

  9. java.lang.IllegalArgumentException: No enum constant org.apache.ws.commons.schema.XmlSchemaForm.

    一次系统断电维护之后,apache cxf 的 web service 接口调用一直报错: java.lang.IllegalArgumentException: No enum constant o ...

随机推荐

  1. GPIO引脚速度的应用匹配

    GPIO 引脚速度: GPIO 引脚速度又称输出驱动电路的响应速度:(芯片内部在I/O口的输出部分安排了多个响应速度不同的输出驱动电路,用户可以根据自己的需要选择合适的驱动电路,通过选择速度来选择不同 ...

  2. jQuery中的常用方法:empty()、each()、$.each()、$.trim()、focus()(二)

    <!DOCTYPE html> <html> <head> <title>02_commonMethod.html</title> < ...

  3. java 常用Bean 转换工具类

    package com.hnf.framework.utils; import com.alibaba.fastjson.JSON; import com.fasterxml.jackson.data ...

  4. 基于SigalR实现的奥运会实时金牌榜

    系统架构 三端 winform 后台数据管理 + Asp.Net Mvc 前台数据展示 + Xamarin.Forms 移动端跨平台APP 因为本人的代码水平一般,期间遇到了一些问题,如signalR ...

  5. linux centos7 df命令

    2021-08-04 1. df 命令简介 linux 中 df 命令的功能是用来检查 linux 服务器的文件系统的磁盘空间占用情况.可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信 ...

  6. js 中连续的 3 个点 three dots (...) in javascript

    这个叫扩展运算符 https://dev.to/sagar/three-dots---in-javascript-26ci 5 种用法 1 function myFunc(...[x, y, z]) ...

  7. Pytest系列(15)- 多重校验插件之pytest-assume的详细使用

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 pytest中可以用pyth ...

  8. TCP协议和套接字

    一.TCP通信概述,逻辑连接就是三次握手 二.客户端和服务端实现TCP协议通信基本步骤 1.客户端套接字对象 Socket 2.服务端套接字ServerSocket 客户端补充完整代码:除了创建各自的 ...

  9. K8s工作流程详解

    在学习k8s工作流程之前,我们得再次认识一下上篇k8s架构与组件详解中提到的kube-controller-manager一个k8s中许多控制器的进程的集合. 比如Deployment 控制器(Dep ...

  10. xshell与小键盘问题

    有些程序员的键盘是带有小数字键的,在使用xshell中文版时就可能出现一些小状况,本集就同大家分析一下使用数字键盘出现乱码的情况怎么办. 图1:使用数字小键盘出现乱码 问题描述: 在xshell上用v ...