Mybatis query error identifying class… Types() or values ()

Time:2021-3-5

We encountered this problem when we learned the relationship of mybatis.

Error instantiating class com.springmvc_mybatis.pojo.Items with invalid types () or values ().

Instantiate a class with an invalid type () or value() com.springmvc_ mybatis.pojo.items There was an error while reading

terms of settlement:

Instantiation failed, which indicates that there is something wrong with the constructor of POJO class. This error is in my entity class. I did not provide a resultmap result set constructor of mybatis. If I add this constructor, I will not report an error.
Mybatis query error identifying class... Types() or values ()
because mapper.xml This constructor is required for a resultmap in

<?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.star.mapper.NewsMapper">
 <resultMap id="BaseResultMap" type="com.star.model.News">
 <constructor>
 <idArg column="news_id" jdbcType="INTEGER" javaType="java.lang.Integer"/>
 <arg column="title" jdbcType="VARCHAR" javaType="java.lang.String"/>
 </constructor>
 </resultMap>
 <! -- news corresponds to multiple type Tags: one to many relationship -- >
 <resultMap id="newsManyToMany" type="com.star.model.News" extends="BaseResultMap">
<!--        <id column="news_id" property="newsId"/>-->
<!--        <result column="title" property="title"/>-->
 <collection property="categories" column="newsId" ofType="com.star.model.Category"
 select="com.star.mapper.CategoryMapper.queryNewsByCategoryId">
 </collection>
 </resultMap>
 <sql id="Base_Column_List">
 news_id, title
    </sql>
 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
 select
        <include refid="Base_Column_List"/>
 from t_news
        where news_id = #{newsId,jdbcType=INTEGER}
 </select>
 <select id="queryCategoryByNewId" resultMap="newsManyToMany">
 select * from t_news nws
 left join t_news_category nct on nws.news_id = nct.nid
        left join t_category ctg on ctg.category_id = nct.cid
        where nws.news_id = #{newsId}
 </select>
 <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
 delete from t_news
    where news_id = #{newsId,jdbcType=INTEGER}
 </delete>
 <insert id="insert" parameterType="com.star.model.News">
 insert into t_news (news_id, title)
 values (#{newsId,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR})
 </insert>
 <insert id="insertSelective" parameterType="com.star.model.News">
 insert into t_news
        <trim prefix="(" suffix=")" suffixOverrides=",">
 <if test="newsId != null">
 news_id,
            </if>
 <if test="title != null">
 title,
            </if>
 </trim>
 <trim prefix="values (" suffix=")" suffixOverrides=",">
 <if test="newsId != null">
 #{newsId,jdbcType=INTEGER},
            </if>
 <if test="title != null">
 #{title,jdbcType=VARCHAR},
            </if>
 </trim>
 </insert>
 <update id="updateByPrimaryKeySelective" parameterType="com.star.model.News">
 update t_news
        <set>
 <if test="title != null">
 title = #{title,jdbcType=VARCHAR},
            </if>
 </set>
 where news_id = #{newsId,jdbcType=INTEGER}
 </update>
 <update id="updateByPrimaryKey" parameterType="com.star.model.News">
 update t_news
    set title = #{title,jdbcType=VARCHAR}
 where news_id = #{newsId,jdbcType=INTEGER}
 </update>
</mapper>