随笔分类 -  SpringBoot原理

摘要:一、异常报告器介绍 1.1 作用 收集错误信息,用于向用户报告错误原因。 1.2 接口定义 二、源码解析 2.1 run 初始化 Spring.facories 中对 SpringBootExceptionReporter 的配置如下: 2.2 handleRunFailure 2.2.1 查看 h 阅读全文
posted @ 2020-03-18 15:31 MarkLogZhu 阅读(1182) 评论(0) 推荐(0) 编辑
摘要:一、Profile 介绍 1.1 Profile 的作用 在日常工作中,项目会处于不同的环境下,如开发、测试、生产等环境。针对不同的环境,各种配置信息也会不同,针对这种情况 Spring 提供了 Profile 机制,实现环境的切换。 1.2激活 Profile 方式 Spring 激活 Profi 阅读全文
posted @ 2020-03-18 13:41 MarkLogZhu 阅读(641) 评论(0) 推荐(0) 编辑
摘要:SpringBoot 配置 一、属性配置方式 新建获取属性值的启动加载器,用来验证设置的属性值: 1.1 硬编码配置 启动项目,查看控制台输出: 1.2 @PropertySource 注解绑定配置 在 resources 目录下新建 default.properties 文件: 在启动类上新增 @ 阅读全文
posted @ 2020-03-18 10:06 MarkLogZhu 阅读(839) 评论(0) 推荐(0) 编辑
摘要:一、什么是启动加载器? 在项目启动的时候做一些初始化工作。 二、启动类加载器实践 2.1 实现 CommandLineRunner 接口 2.2 实现 ApplicationRunner 接口 启动项目,观察控制台输出: 可以看到默认实现 ApplicationRunner 接口比 CommandL 阅读全文
posted @ 2020-03-17 15:11 MarkLogZhu 阅读(1114) 评论(0) 推荐(0) 编辑
摘要:一、refresh 方法 SpringBoot 加载 bean 操作主要在 AbstractApplicationContext 类 refresh 方法里,它的流程图如下: 代码如下: 二、Bean实例化流程 bean 实例化流程流程是在 onRefresh 方法的 finishBeanFacto 阅读全文
posted @ 2020-03-17 14:16 MarkLogZhu 阅读(1515) 评论(0) 推荐(0) 编辑
摘要:一、Banner 介绍 1.1 Banner 是什么? java . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | 阅读全文
posted @ 2020-03-17 08:32 MarkLogZhu 阅读(1229) 评论(0) 推荐(0) 编辑
摘要:一、监听器模式介绍 将一个监听器(listener)与特定的控件(如按钮等)绑定起来,当发生用户点击等事件(Event)时,调用监听器的处理方法,从而响应用户的动作,就叫做事件/监听器模式。 从上面的语句中,我们可以看出监听器模式有三个要素: 事件源 事件对象 监听器 二、自定义监听器事件 创建天气 阅读全文
posted @ 2020-03-16 15:33 MarkLogZhu 阅读(5225) 评论(0) 推荐(0) 编辑
摘要:![](https://images.cnblogs.com/cnblogs_com/markLogZhu/1532657/o_200314075607SpringBoot%E5%90%AF%E5%8A%A8%E6%B5%81%E7%A8%8B.jpg) 阅读全文
posted @ 2020-03-15 13:54 MarkLogZhu 阅读(1506) 评论(0) 推荐(0) 编辑
摘要:一、ApplicationContextInitializer 介绍 1.1 作用 ApplicationContextInitializer 接口用于在 Spring 容器刷新之前执行的一个回调函数,通常用于向 SpringBoot 容器中注入属性。 1.2 内置实现类 DelegatingApp 阅读全文
posted @ 2020-03-15 13:51 MarkLogZhu 阅读(3703) 评论(0) 推荐(0) 编辑
摘要:一、SpringFactoriesLoader 介绍 1.1 SpringFactoriesLoader 简介 SpringFactoriesLoader 工厂加载机制是 Spring 内部提供的一个约定俗成的加载方式,与 java spi 类似,只需要在模块的 META INF/spring.fa 阅读全文
posted @ 2020-03-15 10:59 MarkLogZhu 阅读(1237) 评论(0) 推荐(0) 编辑