Skip to content
项目

maciejwalkowiak/spring-boot-startup-report

在 GitHub 查看

关于

一个为 Spring Boot 应用生成交互式启动报告的库,帮助你了解哪些因素影响应用启动时间,并可能帮助你优化启动过程。

网站与应用开发

这些数字如何统计

可以做什么

  • startup report available in runtime as an interactive HTML page
  • generating startup reports in integration tests
  • search by class or an annotation

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Spring Boot Startup Report

Spring Boot Startup Report library generates an interactive Spring Boot application startup report that lets you understand what contributes to the application startup time and perhaps helps to optimize it.

Open in Gitpod

🤩 Highlights

  • startup report available in runtime as an interactive HTML page
  • generating startup reports in integration tests
  • flame chart
  • search by class or an annotation

Report table lets you dig into the details of beans instantiation:

Report

Flame graphs is a more visual representation of the data from the table:

Report

⚠️ Minimum Requirements

To use the library your project must use following versions

  • Java 8
  • Spring Boot 2.7+, 3.0+

✨ How to use

Note The report generation depends on Jackson present on the classpath. If you already have spring-boot-starter-web or spring-boot-starter-json or any other dependency that brings Jackson - there is nothing to worry about, otherwise make sure to add this to your dependency list:

<dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-databind</artifactId>
 </dependency>
  1. Add the dependency to spring-boot-startup-report:
<dependency>
    <groupId>com.maciejwalkowiak.spring</groupId>
    <artifactId>spring-boot-startup-report</artifactId>
    <version>0.2.0</version>
    <optional>true</optional>
</dependency>
  1. Run application.

  2. Assuming application runs on port 8080, go to http://localhost:8080/startup-report

Note This library has dependencies to org.springframework:spring-test and org.springframework.boot:spring-boot-test so most likely you don't want to include it to your production build and therefore we use it as an optional dependency.

Using with integration tests

When library is on the classpath, it also automatically generates startup reports for each application context started during running integration tests (tests annotated with @SpringBootTest). You'll find them in target/startup-reports for Maven projects and in build/startup-reports for Gradle.

For integration tests that do not use @SpringBootTest but @WebMvcTest, @DataJpaTest or any other test slice, add @Import(StartupEventsAutoConfiguration.class) on the top of the test class to enable generating report.

@Import(StartupEventsAutoConfiguration.class)
@WebMvcTest(OwnerController.class)
public class OwnerControllerTests {
    ...
}

If you need only to generate reports for tests, but do not need to have the report available in runtime under an endpoint, you can declare the dependency with a test scope:

<dependency>
    <groupId>com.maciejwalkowiak.spring</groupId>
    <artifactId>spring-boot-startup-report</artifactId>
    <version>0.2.0</version>
    <scope>test</scope>
</dependency>

Sounds good? Consider ❤️ Sponsoring the project! Thank you!

探索相关项目

加载中…