Mybatis异常:Exception in thread "main" java.lang.ExceptionInInitializerError 解决方法

标签: ExceptionInInitializerError  bug消除  IDEA

BUG消除者(2):

Mybatis异常:

Exception in thread "main" java.lang.ExceptionInInitializerError

错误信息:

错误代码

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qf.dao.UserinfoMapper">
  <resultMap id="BaseResultMap" type="com.qf.pojo.Userinfo">
    <id column="uid" jdbcType="BIGINT" property="uid" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="user_pass" jdbcType="VARCHAR" property="userPass" />
  </resultMap>
  <sql id="Base_Column_List">
    uid, user_name, user_pass
  </sql>

  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from userinfo
    where uid = #{uid,jdbcType=BIGINT}
  </select>
  <!--增删改默认返回的是int,这里没有resultType-->
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from userinfo
    where uid = #{uid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.qf.pojo.Userinfo">
    insert into userinfo (uid, user_name, user_pass
      )
    values (#{uid,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, #{userPass,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.qf.pojo.Userinfo">
    insert into userinfo
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        uid,
      </if>
      <if test="userName != null">
        user_name,
      </if>
      <if test="userPass != null">
        user_pass,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        #{uid,jdbcType=BIGINT},
      </if>
      <if test="userName != null">
        #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userPass != null">
        #{userPass,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.qf.pojo.Userinfo">
    update userinfo
    <set>
      <if test="userName != null">
        user_name = #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userPass != null">
        user_pass = #{userPass,jdbcType=VARCHAR},
      </if>
    </set>
    where uid = #{uid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.qf.pojo.Userinfo">
    update userinfo
    set user_name = #{userName,jdbcType=VARCHAR},
      user_pass = #{userPass,jdbcType=VARCHAR}
    where uid = #{uid,jdbcType=BIGINT}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from userinfo
    where uid = #{uid,jdbcType=BIGINT}
  </select>
  <!--增删改默认返回的是int,这里没有resultType-->
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from userinfo
    where uid = #{uid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.qf.pojo.Userinfo">
    insert into userinfo (uid, user_name, user_pass
      )
    values (#{uid,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, #{userPass,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.qf.pojo.Userinfo">
    insert into userinfo
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        uid,
      </if>
      <if test="userName != null">
        user_name,
      </if>
      <if test="userPass != null">
        user_pass,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="uid != null">
        #{uid,jdbcType=BIGINT},
      </if>
      <if test="userName != null">
        #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userPass != null">
        #{userPass,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.qf.pojo.Userinfo">
    update userinfo
    <set>
      <if test="userName != null">
        user_name = #{userName,jdbcType=VARCHAR},
      </if>
      <if test="userPass != null">
        user_pass = #{userPass,jdbcType=VARCHAR},
      </if>
    </set>
    where uid = #{uid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.qf.pojo.Userinfo">
    update userinfo
    set user_name = #{userName,jdbcType=VARCHAR},
      user_pass = #{userPass,jdbcType=VARCHAR}
    where uid = #{uid,jdbcType=BIGINT}
  </update>
</mapper>

           应该能够看出来xml文件中,增删改查出现了两遍,这显然是不对的.

查找原因:

什么原因导致的呢?原因可能是我利用插件手动点击自动生成了两遍.

这样的话,就会导致xml配置两遍,出现上述Exception in thread "main" java.lang.ExceptionInInitializerError异常.

注意:这只是导致这个异常的一种错误,这里也列出来,希望消除这种异常的时候,提供一个思路

总结:

       IDEA这个异常提示不够精准.期间,也使用了断点调试等,依然没能达到预期要求.可我真的记得明明白白的,我只点击自动生成了一次,然后就去吃饭了,除非,除非有鬼!!!!!当然;将重复代码删除,程序恢复正常.

版权声明:本文为lansexiuzhifu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lansexiuzhifu/article/details/81254558

智能推荐

react-native metro 分析

文章目录 前言 概念 Resolution Transformation Serialization 打包方式 Moudles Plain bundle Indexed RAM bundle File RAM bundle 流程 前置流程 resolve流程 Transformer流程 序列化流程 缓存 为什么要缓存 缓存的请求与缓存 Metro配置 结构 前言 metro是一种支持ReactNa...

嵌入式Linux——应用调试:用户态打印段错误信息

简介:     很多时候我们会遇到段错误:segmentation fault,而段错误有时是由内核引起的,有时是由应用程序引起的。在内核态时,发生段错误时会打印oops信息,但是在用户态时,发生段错误却只会打印segmentation fault而并不会打印其他的信息。所以本文主要介绍在用户态时,通过修改内核设置和添加启动参数来打印引发segmentati...

springboot1.4.1整合logback 遇到的问题

springboot1.4.1整合logback 遇到的问题 项目使用了springboot1.4.1整合logback,然而设置的过期时间15 并没有生效, 2GB达到2G自动删除也没有生效,仅仅实现了按大小分割。 经过查看pom 父工程内的源码发现是默认的logback版本是1.1.7,而过期时间配置是在logback 1.1.8以后才支持的。 不得不说这是springboot1.4.1 的b...

记一次C/S架构的渗透测试

概述 目标站点是http://www.example.com,官网提供了api使用文档,但是对其测试后没有发现漏洞,目录、端口扫描等都未发现可利用的点。后发现官网提供了客户端下载,遂对其进行一番测试。 信息收集 先抓了下客户端的包,使用Fiddler和BurpSuite都抓不到,怀疑走的不是HTTP协议,用WireShark查看其确实用的是HTTP协议,但是数据包不好重放,这里最后使用了WSExp...

Linux:结合Securecrt进行文件上传(lrzsz)P2

1、安装rzsz软件   2、点击Scurecrt的option——X/Y/Z配置上传和下载目录   3、首先在Linux里切换到一个目录,然后用rz命令,文件就会上传到钙Linux的目录下   只要敲rz即可,然后在弹出的对话框里选择需要上传的文件即可 4、下载文件用sz   下载单个文件:在当前目录下有该文件     sz filename   下载...

猜你喜欢

SQL 提示作为 布局 生存工具指南

下面是一些展示AdventureWorks中表现最好的销售人员并列出他们的经理的结构化查询语言代码。 它产生以下结果。 所以,代码是有效的,但它是丑陋的。 如果我需要理解和改进代码,我首先需要把它变成可读的形式。 我有结构化查询语言提示,所以我可以按下计算机的ctrl按键键 踢你自己),它会应用默认的内置代码样式,并对此进行修复。 不,不是,因为我相信你仍然不喜欢它的格式。 没有两个开发人员能够就...

Vue+Springboot解决数据传输时参数格式不匹配问题

前端:使用的是ant design vue ,端口号为8000 后端:使用的是springboot框架开发,端口号为8080 需求:已经解决跨域问题,前端发送登录的信息给后台,后台接收不到 样例: 前端: 后台: 请求的数据格式为json格式,后台参数类型不匹配 解决方案 第一种: 修改后端,参数类型: 第二种方式: 在前端vue框架中加入qs插件,qs 是一个增加了一些安全性的查询字符串解析和序...

Flex布局做出自适应页面--语法和案例

本文发布在: github项目地址:https://github.com/tenadolanter/flex-layout-demo SegmentFault地址:https://segmentfault.com/a/1190000012916949/ CSDN地址:http://blog.csdn.net/qq_34648000/article/details/79115294 博客园地址:ht...

Java - 基于 Apache POI 创建 Excel 文件

基于 Apache POI 创建 Excel 文件 准备 新建 Maven Project,引入依赖: 创建行和列 设置列宽 设置列宽(第 19 行): 注意:其他行的首列的宽度是受第一行、第一列的影响而变宽,并非我们设置的。 设置字体颜色 设置字体颜色(第 25 ~ 31 行): 设置网页超链接 设置网页超链接(第 18、27 ~ 29 行): 参考 java操作excel常用的两种方式...

python基础-质数判断及优化

文章目录 一、问题描述 二、代码 三、问题2优化 四、数学补充 一、问题描述 质数判断条件: 质数是只能被1和它自身整除的数,1不是质数也不是合数。 二、代码 问题1代码 问题2代码 三、问题2优化 优化方案: 模块,通过模块可以对Python进行扩展 引入一个time模块,来统计程序执行的时间 time()函数可以用来获取当前的时间,返回的单位是秒 获取程序开始的时间,以运行时间来衡量优化结果。...