为了账号安全,请及时绑定邮箱和手机立即绑定

报错`Message.xml中报错`

http://img1.sycdn.imooc.com//589c0ff90001391309770229.jpg

错误内容 Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'UserAlias'.  Cause: java.lang.ClassNotFoundException: Cannot find class: UserAlias


<mapper namespace="Message">

  <!-- type对应的哪个实体类,id要在resultMap中唯一  -->

  <resultMap type="bean.Message" id="MessageResult">

    <!-- 数据库中主键用ID标签  -->

    <!-- column对应数据库中的字段名,property对应了实体类中的属性名 ,jdbcType对应了数据库中的属性类型-->

    <id column="ID" jdbcType="INTEGER" property="id"/>

    <!-- 数据库中普通字段用result标签 -->

    <result column="COMMAND" jdbcType="VARCHAR" property="command"/>

    <result column="DESCRIPTION" jdbcType="VARCHAR" property="description"/>

    <result column="CONTENT" jdbcType="VARCHAR" property="content"/>

  </resultMap>

 <!-- Mybatis中的配置信息,应用在一条具体的SQL语句上,通过resultMap标签指向相对应的id名  -->

  <select id="queryMessageList" resultMap="MessageResult">

    select ID,COMMAND,DESCRIPTION,CONTENT from message where 1=1

  </select>


  <select id="version" parameterType="long" resultType="int">

    SELECT version FROM user WHERE id = #{id,jdbcType=INTEGER}

  </select>


  <delete id="delete" parameterType="UserAlias">

    DELETE FROM user WHERE id = #{id:INTEGER}

  </delete>


  <insert id="insert" parameterType="UserAlias" useGeneratedKeys="false">

    INSERT INTO user

    ( id,

    username,

    password,

    administrator

    )

    VALUES

    ( #{id},

    #{username,jdbcType=VARCHAR},

    #{password.encrypted:VARCHAR},

    #{administrator,jdbcType=BOOLEAN}

    )

  </insert>


  <update id="update" parameterType="UserAlias">

    UPDATE user SET

    username = #{username,jdbcType=VARCHAR},

    password = #{password.encrypted,jdbcType=VARCHAR},

    administrator = #{administrator,jdbcType=BOOLEAN}

    WHERE

    id = #{id,jdbcType=INTEGER}

  </update>


  <!--   Unique constraint check -->

  <select id="isUniqueUsername" parameterType="map" resultType="boolean">

    SELECT (count(*) = 0)

    FROM user

    WHERE ((#{userId,jdbcType=BIGINT} IS NOT NULL AND id != #{userId,jdbcType=BIGINT}) OR #{userId,jdbcType=BIGINT} IS

    NULL)  <!-- other than me -->

    AND (username = #{username,jdbcType=VARCHAR})

  </select>

</mapper>



查看了下`是下面的删除和插入等``parameterType="UserAlias"报找不到``如何处理?删掉下面的SQL语句么?

正在回答

2 回答

把你的这个删除就可以了!

<select id="version" parameterType="long" resultType="int">

    SELECT version FROM user WHERE id = #{id,jdbcType=INTEGER}

  </select>


  <delete id="delete" parameterType="UserAlias">

    DELETE FROM user WHERE id = #{id:INTEGER}

  </delete>


  <insert id="insert" parameterType="UserAlias" useGeneratedKeys="false">

    INSERT INTO user

    ( id,

    username,

    password,

    administrator

    )

    VALUES

    ( #{id},

    #{username,jdbcType=VARCHAR},

    #{password.encrypted:VARCHAR},

    #{administrator,jdbcType=BOOLEAN}

    )

  </insert>


  <update id="update" parameterType="UserAlias">

    UPDATE user SET

    username = #{username,jdbcType=VARCHAR},

    password = #{password.encrypted,jdbcType=VARCHAR},

    administrator = #{administrator,jdbcType=BOOLEAN}

    WHERE

    id = #{id,jdbcType=INTEGER}

  </update>


  <!--   Unique constraint check -->

  <select id="isUniqueUsername" parameterType="map" resultType="boolean">

    SELECT (count(*) = 0)

    FROM user

    WHERE ((#{userId,jdbcType=BIGINT} IS NOT NULL AND id != #{userId,jdbcType=BIGINT}) OR #{userId,jdbcType=BIGINT} IS

    NULL)  <!-- other than me -->

    AND (username = #{username,jdbcType=VARCHAR})

  </select>


0 回复 有任何疑惑可以回复我~

删除 

<!-- Mybatis中的配置信息,应用在一条具体的SQL语句上,通过resultMap标签指向相对应的id名  -->

  <select id="queryMessageList" resultMap="MessageResult">

    select ID,COMMAND,DESCRIPTION,CONTENT from message where 1=1

  </select>

之后的sql语句

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
通过自动回复机器人学Mybatis---基础版
  • 参与学习       107417    人
  • 解答问题       786    个

微信公众号自动回复功能学习Mybatis,基础教程加案例实战方式学习

进入课程

报错`Message.xml中报错`

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信