标签: spring

9 篇文章

Spring Boot 启动器
Spring Boot 启动后执行,其实CommandLineRunner和ApplicationRunner并无太大区别,前者通过数组接收启动参数,后者通过ApplicationArguments对象封装了启动参数。 CommandLineRunner import org.springframe…
Spring Bean 生命周期
Bean生命周期 InitializingBean & DisposableBean import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.Initi…
过滤器 vs 拦截器
过滤器 (Filter) 过滤器基于函数回调实现,属于Servlet规范,导致它只能在Web程序使用。 在Application上声明@ServletComponentScan注解 import org.springframework.boot.SpringApplication; import o…
Spring Transactional 事务
@Transactional 事务隔离级别 (Isolation) @Transactional(isolation = Isolation.DEFAULT) 隔离级别说明DEFAULT使用数据库默认的隔离级别,MySQL默认采用REPEATABLE_READ隔离级别,Oracle默认采用READ_…
Spring Event 事件驱动
Spring Event Spring Event只需将事件发布出去,注册的监听器就能针对该事件执行对应的逻辑,轻松实现业务解耦。 定义事件 import org.springframework.context.ApplicationEvent; public class AuditEvent ex…
Spring Boot 静态获取 Bean
ApplicationContextAware接口 import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springfra…
Spring Boot 常用注解
Spring @Configuration与@Bean @Configuration,将一个普通类声明为配置类。 @Bean,将一个普通方法的返回值声明为Spring IOC容器管理的Bean。 import org.springframework.context.annotation.Bean; …
thumbnail
Spring MVC 上传下载
上传 @PostMapping("/import") public ResponseCode<Boolean> importFile(@RequestParam(value = "file") MultipartFile multipartFile) { try (InputStream…
thumbnail
Spring AOP 基本概念
AOP的概念 AOP(Aspect Oriented Programming)面向切面编程,一种使用静态或动态代理的方式在不修改源代码的情况下插入某种通用功能的思想。AOP是OOP(面向对象编程)的补充,利用AOP可以对业务逻辑的各个部分进行隔离,从而减少重复代码,降低模块耦合。 静态代理,AOP框…