摘要: WebMvc常用注解示例 注册模型属性: @ModelAttribute 读取请求头: @RequestHeader 读取 Cookie: @CookieValue 校验参数: @Valid 、@Validated 注解处理: @ExceptionHandler 切面通知: @ControllerA 阅读全文
posted @ 2020-06-04 08:51 樊梨花大大王 阅读(152) 评论(0) 推荐(0) 编辑
摘要: Web MVC 注解驱动 版本要求Spring Framework 3.1 + 基本配置步骤 注解配置: @Configuration ( Spring 范式注解 ) 组件激活: @EnableWebMvc (Spring 模块装配) 自定义组件 : WebMvcConfigurer (Spring 阅读全文
posted @ 2020-06-04 08:42 樊梨花大大王 阅读(291) 评论(0) 推荐(0) 编辑
摘要: SpringBoot加载运行时监听器(SpringApplicationRunListeners) 利用 Spring 工厂加载机制,读取 SpringApplicationRunListener 对象集合,并且封装到组合类 SpringApplicationRunListeners 实现运行时监听 阅读全文
posted @ 2020-06-03 10:27 樊梨花大大王 阅读(829) 评论(0) 推荐(0) 编辑
摘要: SpringBoot加载应用事件监听器 利用 Spring 工厂加载机制,实例化 ApplicationListener 实现类,并排序对象集合 创建应用事件监听器 创建类实现接口ApplicationListener,可以使用@Order或实现Orderd接口进行排序 @Order(Ordered 阅读全文
posted @ 2020-06-03 10:26 樊梨花大大王 阅读(322) 评论(0) 推荐(0) 编辑
摘要: SpringBoot加载应用上下文初始器 利用 Spring 工厂加载机制,实例化 ApplicationContextInitializer 实现类,并排序对象集合。 关键方法 private <T> Collection<T> getSpringFactoriesInstances(Class< 阅读全文
posted @ 2020-06-03 10:25 樊梨花大大王 阅读(452) 评论(0) 推荐(0) 编辑
摘要: Spring boot 自动装配 在 Spring Boot 场景下,基于约定大于配置的原则,实现 Spring 组件自动装配的目的。其中使用了底层装配技术 底层装配技术 Spring 模式注解装配 Spring @Enable 模块装配 Spring 条件装配装配 Spring 工厂加载机制 实现 阅读全文
posted @ 2020-06-02 08:51 樊梨花大大王 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Spring 条件装配 简介 从 Spring Framework 3.1 开始,允许在 Bean 装配时增加前置条件判断 条件注解举例 注解 场景说明 @Profile 配置化条件装配 @Conditional 编程条件装配 实现方式 配置方式,@Profile 编写服务层接口 public in 阅读全文
posted @ 2020-06-01 10:35 樊梨花大大王 阅读(220) 评论(0) 推荐(0) 编辑
摘要: Spring @Enable模块装配 定义 Spring Framework 3.1 开始支持”@Enable 模块驱动“。所谓“模块”是指具备相同领域的功能组件集合, 组合所形成一个独立 的单元。比如 Web MVC 模块、AspectJ代理模块、Caching(缓存)模块、JMX(Java 管 阅读全文
posted @ 2020-06-01 10:33 樊梨花大大王 阅读(269) 评论(0) 推荐(0) 编辑
摘要: resstFul服务文件上传下载 上传 在测试类中使用MocekMvc伪造上传文件请求 @RunWith(SpringRunner.class) @SpringBootTest(classes = DemoApplication.class) public class UserControllerT 阅读全文
posted @ 2020-06-01 09:49 樊梨花大大王 阅读(118) 评论(0) 推荐(0) 编辑
摘要: MockMvc MockMvc import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.s 阅读全文
posted @ 2020-06-01 09:47 樊梨花大大王 阅读(602) 评论(0) 推荐(0) 编辑