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