当前位置:   article > 正文

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

exception in thread "main" java.lang.exceptionininitializererror at dao.use

BUG消除者(2):

Mybatis异常:

Exception in thread "main" java.lang.ExceptionInInitializerError

错误信息:

错误代码

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.qf.dao.UserinfoMapper">
  4. <resultMap id="BaseResultMap" type="com.qf.pojo.Userinfo">
  5. <id column="uid" jdbcType="BIGINT" property="uid" />
  6. <result column="user_name" jdbcType="VARCHAR" property="userName" />
  7. <result column="user_pass" jdbcType="VARCHAR" property="userPass" />
  8. </resultMap>
  9. <sql id="Base_Column_List">
  10. uid, user_name, user_pass
  11. </sql>
  12. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  13. select
  14. <include refid="Base_Column_List" />
  15. from userinfo
  16. where uid = #{uid,jdbcType=BIGINT}
  17. </select>
  18. <!--增删改默认返回的是int,这里没有resultType-->
  19. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  20. delete from userinfo
  21. where uid = #{uid,jdbcType=BIGINT}
  22. </delete>
  23. <insert id="insert" parameterType="com.qf.pojo.Userinfo">
  24. insert into userinfo (uid, user_name, user_pass
  25. )
  26. values (#{uid,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, #{userPass,jdbcType=VARCHAR}
  27. )
  28. </insert>
  29. <insert id="insertSelective" parameterType="com.qf.pojo.Userinfo">
  30. insert into userinfo
  31. <trim prefix="(" suffix=")" suffixOverrides=",">
  32. <if test="uid != null">
  33. uid,
  34. </if>
  35. <if test="userName != null">
  36. user_name,
  37. </if>
  38. <if test="userPass != null">
  39. user_pass,
  40. </if>
  41. </trim>
  42. <trim prefix="values (" suffix=")" suffixOverrides=",">
  43. <if test="uid != null">
  44. #{uid,jdbcType=BIGINT},
  45. </if>
  46. <if test="userName != null">
  47. #{userName,jdbcType=VARCHAR},
  48. </if>
  49. <if test="userPass != null">
  50. #{userPass,jdbcType=VARCHAR},
  51. </if>
  52. </trim>
  53. </insert>
  54. <update id="updateByPrimaryKeySelective" parameterType="com.qf.pojo.Userinfo">
  55. update userinfo
  56. <set>
  57. <if test="userName != null">
  58. user_name = #{userName,jdbcType=VARCHAR},
  59. </if>
  60. <if test="userPass != null">
  61. user_pass = #{userPass,jdbcType=VARCHAR},
  62. </if>
  63. </set>
  64. where uid = #{uid,jdbcType=BIGINT}
  65. </update>
  66. <update id="updateByPrimaryKey" parameterType="com.qf.pojo.Userinfo">
  67. update userinfo
  68. set user_name = #{userName,jdbcType=VARCHAR},
  69. user_pass = #{userPass,jdbcType=VARCHAR}
  70. where uid = #{uid,jdbcType=BIGINT}
  71. </update>
  72. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  73. select
  74. <include refid="Base_Column_List" />
  75. from userinfo
  76. where uid = #{uid,jdbcType=BIGINT}
  77. </select>
  78. <!--增删改默认返回的是int,这里没有resultType-->
  79. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  80. delete from userinfo
  81. where uid = #{uid,jdbcType=BIGINT}
  82. </delete>
  83. <insert id="insert" parameterType="com.qf.pojo.Userinfo">
  84. insert into userinfo (uid, user_name, user_pass
  85. )
  86. values (#{uid,jdbcType=BIGINT}, #{userName,jdbcType=VARCHAR}, #{userPass,jdbcType=VARCHAR}
  87. )
  88. </insert>
  89. <insert id="insertSelective" parameterType="com.qf.pojo.Userinfo">
  90. insert into userinfo
  91. <trim prefix="(" suffix=")" suffixOverrides=",">
  92. <if test="uid != null">
  93. uid,
  94. </if>
  95. <if test="userName != null">
  96. user_name,
  97. </if>
  98. <if test="userPass != null">
  99. user_pass,
  100. </if>
  101. </trim>
  102. <trim prefix="values (" suffix=")" suffixOverrides=",">
  103. <if test="uid != null">
  104. #{uid,jdbcType=BIGINT},
  105. </if>
  106. <if test="userName != null">
  107. #{userName,jdbcType=VARCHAR},
  108. </if>
  109. <if test="userPass != null">
  110. #{userPass,jdbcType=VARCHAR},
  111. </if>
  112. </trim>
  113. </insert>
  114. <update id="updateByPrimaryKeySelective" parameterType="com.qf.pojo.Userinfo">
  115. update userinfo
  116. <set>
  117. <if test="userName != null">
  118. user_name = #{userName,jdbcType=VARCHAR},
  119. </if>
  120. <if test="userPass != null">
  121. user_pass = #{userPass,jdbcType=VARCHAR},
  122. </if>
  123. </set>
  124. where uid = #{uid,jdbcType=BIGINT}
  125. </update>
  126. <update id="updateByPrimaryKey" parameterType="com.qf.pojo.Userinfo">
  127. update userinfo
  128. set user_name = #{userName,jdbcType=VARCHAR},
  129. user_pass = #{userPass,jdbcType=VARCHAR}
  130. where uid = #{uid,jdbcType=BIGINT}
  131. </update>
  132. </mapper>

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

查找原因:

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

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

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

总结:

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/136303
推荐阅读
相关标签
  

闽ICP备14008679号