Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spring Boot Unwrapped - Exploring the Latest Fe...

Spring Boot Unwrapped - Exploring the Latest Features / VDT25

Sergi Almar

January 17, 2025
Tweet

More Decks by Sergi Almar

Other Decks in Programming

Transcript

  1. Hello! I am Sergi Almar Passionate about Spring. Independent Software

    Engineer & Spring Trainer Organizer Spring I/O conference. 3
  2. Spring Boot is moving fast • New major or minor

    version every six months • +1100 contributors, incredibly active community • Continuous innovation . 4
  3. Spring Boot Versions Spring Boot 3.2 Spring Boot 3.3 Spring

    Boot 3.4 Release Date Nov 23, 2023 May 23, 2024 Nov 21, 2024 Spring Framework 6.1.1 6.1.8 6.2.0 5
  4. 6 Main Features Lorem ipsum congue tempus Spring Boot 3.0

    GraalVM Spring AOT Observation API Spring Boot 3.2 Virtual Threads Project CRaC Spring Boot 3.4 Structured Logging Spring Boot 3.1 Testcontainers Docker Compose Spring Boot 3.3 CDS
  5. 7

  6. Metrics with Micrometer 12 • Metrics exposed by Spring Boot

    Actuator • Spring projects are instrumented with Micrometer
  7. Tracing with Micrometer 13 • Micrometer Tracing (no more Spring

    Cloud Sleuth) • Abstraction layer on top of tracing libraries: ◦ Brave ◦ OpenTelemetry
  8. Virtual Threads 15 • Part of Project Loom in JDK

    21 • Single property to opt-in ◦ No code changes required
  9. RestClient 19 • Synchronous HTTP client ◦ Uses the RestTemplate

    infrastructure • Client autoconfiguration ◦ Apache HTTP Components ◦ Jetty Client ◦ Reactor Netty ◦ JDK ◦ Simple JDK
  10. SBOM Endpoint 26 • Exposes the Software Bill of Materials.

    • CycloneDX SBOMs auto-detected. Maven and Gradle plugins ◦ Generates CycloneDX Software Bill of Materials (SBOM) with of all direct and transitive dependencies of a project.
  11. ARM containers • Out-of-the-box support for ARM architecture ◦ imagePlatform

    parameter (linux/amd64, linux/arm64) ◦ Works for native image also 31
  12. Spring Boot CDS • Start your application faster and consume

    less memory ◦ Less improvements compared to native images ◦ But still staying on the JVM 33 Training Run CDS Archive Production Run
  13. Exploded JAR • Running CDS on an executable JAR is

    not recommended ◦ loading classes from nested jars has a startup cost ◦ running the app from an exploded JAR is faster and recommended in prod 34 vdt25application.jar libs
  14. CDS Archive • Spring Boot offers a convenient way to

    build a CDS archive • Specify these two options when starting you app ◦ -XX:ArchiveClassesAtExit=application.jsa ◦ -Dspring.context.exit=onRefresh 35 Training Run CDS Archive
  15. Running with CDS • Specify the CDS archive when running

    the application • Some constraints ◦ Must use the same JVM utilized for creating the archive ◦ Same classpath 36 CDS Archive Production Run
  16. 38 CDS and Buildpacks • Performs automatically the training run.

    • Extract the Spring Boot executable JAR to the CDS friendly file layout • Adds the CDS archive in the container. • Automatically enables CDS when running the container image.
  17. Bean Overriding • Spring Boot disables bean definition overriding by

    default. • TestContext framework introduces new bean overriding support ◦ Based on @BeanOverride meta-annotation and associated infrastructure ◦ @TestBean, @MockitoBean and @MockitoSpyBean 41
  18. @TestBean • @TestBean allows overriding a specific bean in the

    test’s ApplicationContext ◦ Providing a static factory method 42
  19. MockMvcTester • The regular MockMvc uses Hamcrest. • The new

    MockMvcTester uses AssertJ. ◦ Wraps MockMvc • @AutoConfigureMockMvc and @WebMvcTest autoconfigures: ◦ MockMvc ◦ MockMvcTester (if AssertJ is on the classpath) 47
  20. Other Features • Graceful shutdown by default. • Fragment Rendering

    • Background bean initialization • Fallback beans • Content negotiation for @ExceptionHandler methods • Testcontainers improvements • … 50
  21. Upgrading • Better performance and startup times • New features

    • Security Updates • Review the release notes and migration guides • Refactor or remove deprecated APIs / properties • Test! 52
  22. Spring Boot Roadmap Spring Boot 3.5 Spring Boot 4.0 Scheduled

    Date May 2025 Nov 2025 Spring Framework 6.2.x 7.0 54 https:/ /spring.io/blog/2024/10/01/from-spring-framework-6-2-to-7-0
  23. “ Thank you ❤ Spring team! Java 21, virtual threads,

    CDS, Observability, Buildpacks, Autoconfiguration, simple abstractions… 55
  24. 56 Thanks! Any questions? You can find me on X

    (@sergialmar) or Bsky (@sergialmar.com)