项目学习

1.怎么创建数据库表
字符集:utf8mb4
排序规则:utf8mb4_unicode_ci
2.数据库的三范式、了解数据库的CRUD语句

-- SELECT * FROM sysuser;
-- INSERT INTO sysuser(username, password) VALUES('harzer', '000000');
-- UPDATE sysuser set password = '111111' WHERE id = 2;
-- ;
-- SELECT * FROM sysuser;
-- SELECT * FROM sysuser LIMIT 0, 1;前一位限制开始位置, 后一位限制查询数量, 若只有一位数字则限制查询数量

3.UserMapper.xml 与UserDao接口连接方法、

<?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.example.springboot.dao.UserDao">
</mapper>

4.Autowired注解
5. @RequestBody
6. @PostMapping
7. @Validated
*参数

@AssertFalse 校验false
@AssertTrue 校验true
@DecimalMax(value=,inclusive=) 小于等于value,inclusive=true,是小于等于
@DecimalMin(value=,inclusive=) 与上类似
@Max(value=) 小于等于value
@Min(value=) 大于等于value
@NotNull 检查Null
@Past 检查日期
@Pattern(regex=,flag=) 正则
@Size(min=, max=) 字符串,集合,map限制大小
@Validate 对po实体类进行校验

  1. @PutMapping 更新资源
    *资源区分:
    1.url路径
    2.url相同时根据请求方式 获得的资源不同
    9.@DeleteMapping
    10.常见错误
  • NoSuchBeanDefinitionException
    描述:SpringbootApplicationTests.contextLoads » IllegalState Failed to load ApplicatNo qualifying bean of type 'com.example.springboot.dao.UserDao' available
    解决方法:在对应的Dao中加入@Mapper

    对应的数据库要修改为项目名
    *前端报错
    通过DAO接口的返回值,自动检错
{
 "timestamp": "2023-02-09T04:40:30.508+00:00",
 "status": 500,
 "status": 500,
 "error": "Internal Server Error",
 "message": "",
 "path": "/"
}

通过#id去接收参数,预编译,防止sql注入
*sql语句错误

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

原因:参数错误
解决方法:
解决方法:
1.去掉所有分号‘;’
2.还有不必要的空格
3.检查参数的类型
4.检查‘#’的位置,SELECT*FROMsysuserwhereid=#{id}
*{GET /user}
错误描述:There is already 'userController' bean method
原因:同一个controller里面定义了2个或多个相同路径的接口
*参数判断错误
Dao里面要对于多参数的函数要在方法参数里面加入@Param说明参数 ,否则可能报错

UsergetByUser(@Param("username")Stringusername,@Param("password")Stringp assword);

*405错误: 表示资源请求方式不对,比如后台接口是POST,而前端使用了GET请求,这时候出现了405的Http错误
*404错误:请求的接口不存在

posted @ 2023-02-09 19:51  绵羊爱喝AD钙  阅读(13)  评论(0)    收藏  举报