Spring Boot


1、热部署

热部署

热部署配置:
热部署配置

2、SpringBoot资源文件属性配置

Spring Boot资源文件属性配置;
必须在Pom.xml中进行配置。
config

3、SpringBoot资源文件配置server

3.1 Server服务端相关配置

server

3.2 资源文件中配置tomcat相关属性

tomcat

4、SpringBoot整合模板引擎

4.1 整合freemarker

引入依赖:
freemarker


配置: ![freemarker配置](https://img-blog.csdn.net/20180905092638465?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0FuMTA5MDIzOTc4Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)

4.2 整合thymeleaf

引入依赖:
thymeleaf

配置:
thymeleaf配置

5、SpringBoot配置全局的异常捕获

5.1 页面跳转形式

页面跳转

5.2 ajax形式

ajax


5.3 统一返回异常的形式

ajax判断


统一异常

6、SpringBoot整合redis

首先,pom.xml中引入依赖,然后在资源文件中对redis进行配置。

redis


![redis配置](https://img-blog.csdn.net/20180905100518691?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0FuMTA5MDIzOTc4Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)

a

7、SpringBoot整合定时任务task

使用注解@EnableScheduling开启定时任务,会自动扫描。

定义@Component作为组件被容器扫描。

定时任务


组件


7.1 定时任务表达式的应用:

表达式生产地址:http://cron.qqe2.com

b

8、SpringBoot整合异步任务

使用注解@EnableAsynv开启异步,会自动扫描。

定义@Component @Async作为组件被容器扫描执行 。

异步任务


c

使用场景:
- 发送短信
- 发送邮件
- APP消息推送
- 节省运维凌晨发布任务时间提供效率

9、SpringBoot拦截器的使用

使用注解@Configuration配置拦截器。

继承WebMvcConfigurerAdapter。

重写addInterceptors添加需要的拦截器地址。

拦截器

拦截器1

拦截器2

拦截器3

拦截器4

10、springboot指定端口的三种方式

第一:配置文件中添加server.port=9090

第二:在命令行中指定启动端口,比如传入参数一server. port=9000 java -jar bootsample. jar – server.port=9000

第三:传入虚拟机系统属性java - Dserver.port=9000 -jar bootsample.jar

原文地址:https://www.cnblogs.com/aixing/p/13327512.html