MybatisPlus未加主键问题

Can not find table primary key in Class: “com.wyt.springboot_redis.pojo.Users”.
2022-04-03 00:12:57.124 WARN 18748 — [ main] c.b.m.core.injector.DefaultSqlInjector : class com.wyt.springboot_redis.pojo.Users ,Not found @TableId annotation, Cannot use Mybatis-Plus ‘xxById’ Method.
2022-04-03 00:12:57.249 INFO 18748 — [ main] c.w.s.SpringbootRedisApplicationTests : Started SpringbootRedisApplicationTests in 5.801 seconds (JVM running for 7.145)

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wyt.springboot_redis.mapper.UsersMapperM.selectById

解决方案

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Users {
   @TableId(value = "userid" ,type= IdType.AUTO)//很重要没有在实体类的自增主键上加自增主键的注解
    private int userid;
    private String username;
    private String usersex;
}

你可能感兴趣的:(未经分类的博客,java)