springboot启动配置原理_小学生ii-编程思维
https://cloud.tencent.com/developer/article/1802822?from=article.detail.1449134 # SpringBoot启动配置原理 几个重要的事件回调机制 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListene
morethink program
https://cloud.tencent.com/developer/article/1802822?from=article.detail.1449134 # SpringBoot启动配置原理 几个重要的事件回调机制 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListene
thymeleaf语法: ${...} 获取请求域、session域、对象等值 session.setAttribute("loginUser",user); # 向HttpSession中添加数据 session.getAttribute("loginUser"); # 获取HttpSession中的数据 model.addAttribu
拦截器实现步骤: 1、编写一个拦截器实现HandlerInterceptor接口 2、拦截器注册到容器中(实现WebMvcConfigurer的addInterceptors) 3、指定拦截规则,如果是拦截所有,静态资源也会被拦截 编写一个拦截器 public class LoginInterceptor implements HandlerInterceptor { /
使用原生注解注入servlet组件:@WebServlet处理请求路由,+主配置类中标注@ServletComponentScan扫描原生注解所在的路径 @WebServlet(urlPatterns = "/my") public class MyServlet extends HttpServlet { @Override protected void doGet(Htt
spring方式注入servlet组件:普通类 + ServletRegistrationBean + @ServletComponentScan # 编写普通类 public class MyServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpSe
使用@WebServlet(urlPatterns = "/my")时直接响应,没有经过Spring的拦截器 DispatchServlet 如何注册进来 容器中自动配置了 DispatcherServlet 属性绑定到 WebMvcProperties;对应的配置文件配置项是 spring.mvc。 通过 ServletRegistrationBean<DispatcherSer
JUnit5组成 JUnit Platform: Junit Platform是在JVM上启动测试框架的基础,不仅支持Junit自制的测试引擎,其他测试引擎也都可以接入。 JUnit Jupiter: JUnit Jupiter提供了JUnit5的新的编程模型,是JUnit5新特性的核心。内部 包含了一个测试引擎,用于在Junit Platform上运行。 JUnit Vintage: 由于
简介 断言(assertions)是测试方法中的核心部分,用来对测试需要满足的条件进行验证。这些断言方法都是 org.junit.jupiter.api.Assertions 的静态方法 检查业务逻辑返回的数据是否合理。 所有的测试运行结束以后,会有一个详细的测试报告 简单断言 案例 # 当前面执行的断言失败后,后面的断言不会执行 @Test @DisplayName("s
前置条件可以看成是测试方法执行的前提,当该前提不满足时,就没有继续执行的必要 # assumingThat 的参数是表示条件的布尔值和对应的 Executable 接口的实现对象。只有条件满足时,Executable 对象才会被执行;当条件不满足时,测试执行并不会终止 @DisplayName("前置条件") public class AssumptionsTest { private
指标监控暴露方式 jmx http jmx默认是开启的,使用jmx查看 启动项目 打开cmd,输入jconsole 连接启动的应用 http查看步骤: # 添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spri
yml配置,方便查看 management: health: enabled: true show-details: always #总是显示详细信息。可显示每个模块的状态信息 定制 Health 信息 @Component public class MyComHealthIndicator extends AbstractHealthIndicator
构建1个新项目作为收集数据的服务器 pom.xml中导入依赖 <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>
配置文件激活 当我们的项目部署到线上之后,部署环境和开发环境不同,这时可写多个配置文件,在不同的环境指定不同的配置文件 例如用于默认,生产,测试环境的配置文件: application.properties application-prod.yaml application-test.yaml 我们在默认配置文件中指定使用哪个配置文件,application.properties
常用外部配置源 Java属性文件、YAML文件、环境变量、命令行参数; 启动类中获取环境变量 @SpringBootApplication public class Boot09FeaturesProfileApplication { public static void main(String[] args) { ConfigurableApplicatio
新建1个项目,并在里面新建2个子模块 atguigu-hello-spring-boot-starter作为启动器 atguigu-hello-spring-boot-starter-autoconfigure用于自动配置包 启动器子模块中添加配置包 <dependencies> <dependency> <groupId>
SpringBoot启动过程 ● 创建 SpringApplication ○ 保存一些信息。 ○ 判定当前应用的类型。ClassUtils。Servlet ○ bootstrappers:初始启动引导器(List<Bootstrapper>):去spring.factories文件中找 org.springframework.boot.Bootstrapper
参考文档 视频教程 源码地址 springboot查看官方文档 https://spring.io/ 查看官方文档 查看新版本特性 yml配置文档 构建1个spring boot项目 先创建1个maven项目,导入依赖 <parent> <groupId>org.springframework.boot<
依赖管理 # 在自己项目中引入的依赖为如下 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.4.RELEASE</v
Full模式与Lite模式 配置类组件之间无依赖关系用Lite模式加速容器启动过程,减少判断 配置类组件之间有依赖关系,方法会被调用得到之前单实例组件,用Full模式 如下有1个配置类,配置类中有2个方法 /** * 1、配置类里面使用@Bean标注在方法上给容器注册组件,默认也是单实例的 * 2、配置类本身也是组件 * 3、proxyBeanMethods:代理bean的方法
使用@Import注解,给容器中自动创建出这两个类型的组件、默认组件的名字就是全类名 @Import({User.class, DBHelper.class}) @Configuration(proxyBeanMethods = false) //告诉SpringBoot这是一个配置类 == 配置文件 public class MyConfig { } @Conditional使用 条