spring boot 的sql插入语句报错是为什么
数据库都连接了,查了很久也没有解决
有时候是开发工具的校验,先看下程序能不能运行
1、优先看数据能不能插入
2、如果能插入看是不是编译器报的错,并不影响
【相关推荐】
1.查
@Select("select * from users")
List<Users> AllUser();
2.改
//注意要加script标签
@Update("<script> " + "update users" +
"<set>" + "<if test=\"name != null and name !=''\">name=#{name},</if>" +
"<if test=\"nickname != null and nickname !=''\">nickname=#{nickname},</if>" +
"<if test=\"url != null and url !=''\">url=#{url},</if>" +
"<if test=\"sex != null and sex !=''\">sex=#{sex},</if>" +
"<if test=\"age !=null and age !=''\">age=#{age},</if>" +
"<if test=\"password !=null and password !=''\">password=#{password},</if>" +
"</set>" + "where id=#{id}" +
" </script> ")
int updateTest(Users users);
3.增
@Insert("insert into users (id,name,telephone,nickname,salt,userstate,password,jid,udate)\n" +
"VALUES(#{id},#{name},#{telephone},#{nickname},#{salt},'01',#{password},'03',now())")
int in(Users users);
4.删
@Delete("delete from users where id = #{id}")
int delete(String id);
5.模糊查询(根据姓名和登记日期模糊查询所有数据)
@Select({"select * from putong_rencai where concat(name,dengji_time) like '%' || 'search_name' || '%' "})
public List<PuTongUser> selectMohu(@Param("search_name") String search_name);
个人觉得这个比mapper.xml要方便一些但是一些复杂的表关系还是不要用了,例如多对多一对多关系这种的
看一下控制层是不是没加@RequestBody注解,导致获取不到参数值,或者是不是表单提交