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

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值