查看SpringBoot启动过程分析性能问题
- 启动类配置-BufferingApplicationStartup
@SpringBootApplication
public class SpringBoot01Application {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(SpringBoot01Application.class);
springApplication.setApplicationStartup(new BufferingApplicationStartup(2048));
springApplication.run(args);
}
}
- 兼容处理(Jackson + jdk8)-添加jdk对于jdk8日期序列化的处理 3.1 添加pom依赖
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.17.1</version>
</dependency>
3.2 设置ObjectMapper支持jdk8日期格式
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
- 打印过程
@EventListener
public void onApplicationEvent(ApplicationReadyEvent event) throws JsonProcessingException {
log.info("在调用任何应用程序和命令行运行器之后:{}",event.getClass().getSimpleName());
BufferingApplicationStartup bean = applicationContext.getBean(BufferingApplicationStartup.class);
StartupTimeline bufferedTimeline = bean.getBufferedTimeline();
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
log.info("启动时间线:{}",objectMapper.writeValueAsString(bufferedTimeline));
}