SpringBoot
springboot 入门项目详解
入门项目详解:SpringBoot 入门知识点详解
springboot 配置文件的拆分
springboot 组件管理 + 注入
springboot 集成 Jsp、Thymeleaf 模板
SpringBoot 集成 JSP、Thymeleaf 模板 + Thymeleaf 基本使用
springboot 集成 Mybatis
springboot 开启热部署
SpringBoot 开启热部署(jsp 页面热部署、devtools 全局热部署)
springboot 中 logback 日志的集成
面向切面编程
具体:静态代理设计模式、Spring 动态代理开发详解、切入点详解(切入点表达式、切入点函数)
springboot 是对原有项目中 spring 框架 和 springmvc 的近一步封装,因此在 springboot 中同样支持spring 框架中 AOP切面编程,不过在 springboot 中为了快速开发仅仅提供了注解方式的切面编程。
引入依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
相关注解:
@Aspect
用在类上,代表这个类是一个 切面;@Before
用在方法上,代表这个方法是一个 前置通知方法;@After
用在方法上,代表这个方法是一个 后置通知方法;@Around
用在方法上,代表这个方法是一个 环绕的方法;
注意:环绕通知存在返回值,参数为 ProceedingJoinPoint
,如果执行放行,不会执行目标方法,一旦放行必须将目标方法的返回值返回,否则调用者无法接受返回数据。
@Aspect // 切面
@Configuration // 允许被扫描到
// @Order(2) // 多个切面的执行顺序(越小越优先)
public class MyAspect {
// 环绕通知: 当目标方法执行时会先进入环绕通知, 然后再环绕通知放行之后进入目标方法,
// 然后执行目标方法, 目标方法执行完成之后回到环绕通知
@Around("within(com.yusael.service.*ServiceImpl)")
public Object arount0(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("进入环绕通知业务处理0~~");
System.out.println("目标方法名称: " + pjp.getSignature().getName());
System.out.println("目标对象: " + pjp.getTarget());
Object proceed = pjp.proceed();// 放行执行业务
System.out.println("业务方法执行之后的业务处理0~~");
System.out.println(proceed);
return proceed;
}
// 前置通知方法: 在目标方法执行之前执行操作
@Before("within(com.yusael.service.*ServiceImpl)")
public void before(JoinPoint joinPoint) {
System.out.println("目标方法名称: " + joinPoint.getSignature().getName());
// System.out.println("目标方法参数: " + joinPoint.getArgs()[0]);
System.out.println("目标对象: " + joinPoint.getTarget());
System.out.println("前置通知业务的处理↑~~");
}
// 后置方法通知: 再目标方法执行之后执行操作
@After("within(com.yusael.service.*ServiceImpl)")
public void after(JoinPoint joinPoint) {
System.out.println("后置通知的业务处理↓~~");
System.out.println("目标方法名称: " + joinPoint.getSignature().getName());
// System.out.println("目标方法参数: " + joinPoint.getArgs()[0]);
System.out.println("目标对象: " + joinPoint.getTarget());
}
}
文件上传下载
springboot文件上传下载实战 —— 登录功能、展示所有文件
springboot文件上传下载实战 ——文件上传、下载、在线打开、删除