Mybatis项目:Parameter ‘id’ not found. Available parameters are [provider, param1]

请尝试删除掉接口中的参数注解

原代码↓
接口:

//增加用户信息
    public int add(@Param("provider") Provider provider);

映射:

<insert id="add" parameterType="provider">
        insert into smbms_provider (id,proCode,proName,
        proDesc,proContact,proPhone,proAddress,proFax,
        createdBy,creationDate,modifyBy,modifyDate)
		values (#{id},#{proCode},#{proName},#{proDesc},
		#{proContact},#{proPhone},#{proAddress},#{proFax},
		#{createdBy},#{creationDate},#{modifyBy},#{modifyDate})
    insert>

测试类

		@Test
        public void add(){
     
            SqlSession sqlSession = MybatisUtils.getSqlSession();
            ProviderMapper mapper = sqlSession.getMapper(ProviderMapper.class);
            Provider provider = new Provider(21,"ZJ_GYS002",
                    "乐摆日用品厂2","长期合作伙伴,主营产品:2",
                    "王世杰","13212331567",
                    "浙江省金华市义乌市义东路",
                    "0579-34452321",1,new Date(),
                    null,null);
            mapper.add(provider);
            sqlSession.close();
        }

报错

Cause: org.apache.ibatis.binding.BindingException: 
Parameter 'id' not found. Available parameters are [provider, param1]

找了一些方法都没有成功,但是好像和注解脱不了关系。修改接口,删除掉注解

//增加用户信息
    public int add(Provider provider);

运行成功
Mybatis项目:Parameter ‘id’ not found. Available parameters are [provider, param1]_第1张图片

你可能感兴趣的:(mybatis,java)