-
在Spring中@RestController的作用等同于@Controller + @ResponseBody。
在Spring中@GetMapping()/@PostMapping等同于传统的@RequestMapping来编写应该是@RequestMapping(value = “”}, method = RequestMethod.GET/POST)
查看全部 -
使用快捷键 alt + insert 唤起Generate弹窗
查看全部 -
com.mysql.jdbc.Driver数据库驱动已经弃用,需要更换为com.mysql.cj.jdbc.Driver驱动
查看全部 -
@Conroller和@ResponseBody等同于ResConroller查看全部
-
@CookieValue,@Header需要使用一下
查看全部 -
MariaDB


查看全部 -
@RequestBody
查看全部 -
lombok

查看全部 -
@Value

查看全部 -
Postman
查看全部 -
SpringBootApplication

查看全部 -
MVC


查看全部 -

@Configuration // 1.标志配置类,使得springboot容器可以扫描到 @EnableScheduling // 2.开启定时任务 @Slf4j public class MyTask { //3.添加一个任务,并且注明任务的运行表达式 @Scheduled(cron = "*/5 * * * * ?") public void publishMsg(){ log.warn("开始执行任务"+ LocalDateTime.now()); } /* * 分布式不适用 * */查看全部 -
* 自义定异常
* 目的:
* 统一处理异常
* 便于解耦,可以在拦截器,控制层,业务侧去使用
* 比如正常情况返回前端是list,错误是string 解耦后错误返回异常就行public class MyCustomException extends RuntimeException{ public MyCustomException(String erroMsg) { super(erroMsg); } }
* 优雅的处理异常,进行调用
* */public class GraceException { public static void display(String errMsg){ throw new MyCustomException(errMsg); } }//调用
if (!"1001".equals(userId) || !"abc".equals(userToken)){ log.error("用户校验不通过,信息不匹配"); GraceException.display("用户校验不通过,信息不匹配"); return false; }查看全部 -
spring:
servlet:
multipart:
file-size-threshold: 500KB # 文件上传的大小限制,设置最大值,不能超过
max-request-size: 2MB # 请求的最大值,用于批量查看全部
举报













