随笔分类 -  Spring全家桶

Spring框架全家桶,如Spring,SpringBoot,SpringSecurity,SpringDataJpa,SpringCloud等
摘要:Spring Mvc 跨域访问 跨域访问 当前页面渲染请求为 http://localhost:8080/index.html <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>CORS 示例</titl 阅读全文
posted @ 2020-06-08 09:12 樊梨花大大王 阅读(192) 评论(0) 推荐(0)
摘要:扩展 REST 内容协商 核心组件 组件名称 实现 说明 内容协商管理器 ContentNegotiationManager ContentNegotiationStrategy 控制策略 媒体类型 MediaType HTTP 消息媒体类型,如 text/html 消费媒体类型 @RequestM 阅读全文
posted @ 2020-06-08 08:50 樊梨花大大王 阅读(148) 评论(0) 推荐(0)
摘要:Spring Mvc 自动装配 版本要求 Spring Framework 3.1 + Servlet 3.0 + Servlet SPI Servlet SPI ServletContainerInitializer ,参考 Servlet 3.0 规范 配合 @HandlesTypes Spri 阅读全文
posted @ 2020-06-04 09:03 樊梨花大大王 阅读(256) 评论(0) 推荐(0)
摘要:WebMvc常用注解示例 注册模型属性: @ModelAttribute 读取请求头: @RequestHeader 读取 Cookie: @CookieValue 校验参数: @Valid 、@Validated 注解处理: @ExceptionHandler 切面通知: @ControllerA 阅读全文
posted @ 2020-06-04 08:51 樊梨花大大王 阅读(161) 评论(0) 推荐(0)
摘要:Web MVC 注解驱动 版本要求Spring Framework 3.1 + 基本配置步骤 注解配置: @Configuration ( Spring 范式注解 ) 组件激活: @EnableWebMvc (Spring 模块装配) 自定义组件 : WebMvcConfigurer (Spring 阅读全文
posted @ 2020-06-04 08:42 樊梨花大大王 阅读(300) 评论(0) 推荐(0)
摘要:SpringBoot加载运行时监听器(SpringApplicationRunListeners) 利用 Spring 工厂加载机制,读取 SpringApplicationRunListener 对象集合,并且封装到组合类 SpringApplicationRunListeners 实现运行时监听 阅读全文
posted @ 2020-06-03 10:27 樊梨花大大王 阅读(856) 评论(0) 推荐(0)
摘要:SpringBoot加载应用事件监听器 利用 Spring 工厂加载机制,实例化 ApplicationListener 实现类,并排序对象集合 创建应用事件监听器 创建类实现接口ApplicationListener,可以使用@Order或实现Orderd接口进行排序 @Order(Ordered 阅读全文
posted @ 2020-06-03 10:26 樊梨花大大王 阅读(332) 评论(0) 推荐(0)
摘要:SpringBoot加载应用上下文初始器 利用 Spring 工厂加载机制,实例化 ApplicationContextInitializer 实现类,并排序对象集合。 关键方法 private <T> Collection<T> getSpringFactoriesInstances(Class< 阅读全文
posted @ 2020-06-03 10:25 樊梨花大大王 阅读(479) 评论(0) 推荐(0)
摘要:Spring boot 自动装配 在 Spring Boot 场景下,基于约定大于配置的原则,实现 Spring 组件自动装配的目的。其中使用了底层装配技术 底层装配技术 Spring 模式注解装配 Spring @Enable 模块装配 Spring 条件装配装配 Spring 工厂加载机制 实现 阅读全文
posted @ 2020-06-02 08:51 樊梨花大大王 阅读(164) 评论(0) 推荐(0)
摘要:Spring 条件装配 简介 从 Spring Framework 3.1 开始,允许在 Bean 装配时增加前置条件判断 条件注解举例 注解 场景说明 @Profile 配置化条件装配 @Conditional 编程条件装配 实现方式 配置方式,@Profile 编写服务层接口 public in 阅读全文
posted @ 2020-06-01 10:35 樊梨花大大王 阅读(232) 评论(0) 推荐(0)
摘要:Spring @Enable模块装配 定义 Spring Framework 3.1 开始支持”@Enable 模块驱动“。所谓“模块”是指具备相同领域的功能组件集合, 组合所形成一个独立 的单元。比如 Web MVC 模块、AspectJ代理模块、Caching(缓存)模块、JMX(Java 管 阅读全文
posted @ 2020-06-01 10:33 樊梨花大大王 阅读(282) 评论(0) 推荐(0)
摘要:resstFul服务文件上传下载 上传 在测试类中使用MocekMvc伪造上传文件请求 @RunWith(SpringRunner.class) @SpringBootTest(classes = DemoApplication.class) public class UserControllerT 阅读全文
posted @ 2020-06-01 09:49 樊梨花大大王 阅读(127) 评论(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 樊梨花大大王 阅读(620) 评论(0) 推荐(0)
摘要:resstFul服务文件上传下载 上传 在测试类中使用MocekMvc伪造上传文件请求 @RunWith(SpringRunner.class) @SpringBootTest(classes = DemoApplication.class) public class UserControllerT 阅读全文
posted @ 2020-06-01 09:44 樊梨花大大王 阅读(125) 评论(0) 推荐(0)
摘要:SpringBoot 拦截RestFul 服务 使用拦截器 使用@Component注解并继承HandlerInterceptor接口,拦截的controller类中的方法 @Component public class CustomInterceptor implements HandlerInt 阅读全文
posted @ 2020-06-01 09:43 樊梨花大大王 阅读(427) 评论(0) 推荐(0)
摘要:SringBoot 异常处理 Spring Boot 中默认的错误处理机制 spring boot 应用默认对浏览器请求和Http请求错误处理不同方法 spring boot 默认异常处理类 @Controller @RequestMapping("${server.error.path:${err 阅读全文
posted @ 2020-06-01 09:23 樊梨花大大王 阅读(199) 评论(0) 推荐(0)
摘要:springBoot核心技术概览 核心特性 组件自动装备(webMVC, web Flux,JDBC等) 激活: @EnableAutoConfiguration 配置: /META-INF/spring.factories 实现: XXXAutoConfiguration 嵌入式Web容器 Web 阅读全文
posted @ 2020-06-01 09:22 樊梨花大大王 阅读(407) 评论(0) 推荐(0)