Spring boot
Spring boot学习笔记
Quick Start
3. 创建Example.java
* 目录:src/main/java/Example.java
```java
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;
@RestController
@EnableAutoConfiguration
public class Example {
@RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(Example.class, args);
}
}注解开发
1. @SpringBootApplication
2. @RestController
3.@RequestMapping,@PathVariable
4.@GetMapping
5.@RequestParam
6.@RequestBody
7.@RequestHeader
8.HttpServletRequest
其它Http请求
json处理(jackson)
spring-boot 目录结构
引入thymeleaf
其它静态资源
默认配置
更改配置写入自定义静态资源文件夹
文件上传
硬编码方式修改文件上传大小限制
打包jar包
文件服务器
不被热部署的文件
指定不进行热部署的文件
单元测试
引入依赖
普通测试
API测试
个性化启动banner设置和debug日志
配置全局异常处理
自定义异常捕获
部署war包于tomcat中
配置自定义过滤器
Servlet3.0自定义原生Listerner
spring boot2.0拦截器
修改启动类 增加 mapperScan扫描mapper
配置数据源
编写mapper
service调用
controller调用
其它mapper
事务
事务出错回滚
Redis
相关链接
linux下
简单使用
Redis桌面应用
封装工具类
定时任务与异步任务处理
定时任务
启动类增加新注解
使用 (testTimerTask.class)
异步任务
启动类添加注解
异步任务类
业务调用
等待异步回调完成
Last updated
Was this helpful?