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

Improve Your Developer Experience with Spring Boot Dev Services

Improve Your Developer Experience with Spring Boot Dev Services

We all use Docker (and Docker Compose) to provide the external services we develop against, say, a PostgreSQL database. Wouldn't it be great if Spring Boot knows there are external services needed and then auto-configures itself to use them? In this talk, we will show you an upcoming new feature of Spring Boot that will certainly improve your developer experience.

https://www.youtube.com/watch?v=Yqss7tYP890&list=PLgGXSWYM2FpPrAdQor9pi__EV1O69Qbom&index=8

Moritz Halbritter

September 18, 2023
Tweet

More Decks by Moritz Halbritter

Other Decks in Programming

Transcript

  1. #vmwareexplore #
    Improve Your Developer
    Experience with Spring
    Boot Dev Services
    SPB1212LV
    Moritz Halbritter (He/Him)
    SE, VMware
    SPB1212LV
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  2. © VMware, Inc. 2
    This presentation may contain product features or functionality that are currently
    under development.
    This overview of new technology represents no commitment from VMware to deliver these
    features in any generally available product.
    Features are subject to change, and must not be included in contracts, purchase orders, or sales
    agreements of any kind.
    Technical feasibility and market demand will affect final delivery.
    Pricing and packaging for any new features/functionality/technology discussed
    or presented, have not been determined.
    Required Disclaimer
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  3. © VMware, Inc. 3
    What‘s the Problem?
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  4. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  5. © VMware, Inc. 5
    What‘s Creating
    the Problem?
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  6. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  7. © VMware, Inc. 7
    What’s the solution?
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  8. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  9. © VMware, Inc. 9
    Docker Compose in Spring
    Boot 3.1
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  10. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  11. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  12. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  13. © VMware, Inc.
    url = jdbc:postgresql://127.0.0.1:32771/mydatabase
    username = myuser
    password = secret
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  14. © VMware, Inc. 14
    Digression:
    ConnectionDetails
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  15. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  16. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  17. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  18. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  19. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  20. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  21. © VMware, Inc. 21
    Back to Docker Compose…
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  22. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  23. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  24. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  25. © VMware, Inc. 25
    How-to: Use Custom Images
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  26. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  27. © VMware, Inc. 27
    How-to: Ignore Services
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  28. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  29. © VMware, Inc. 29
    How-to: Share Services
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  30. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  31. © VMware, Inc. 31
    Testcontainers in Spring Boot
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  32. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  33. © VMware, Inc. 33
    Integration Tests with
    Testcontainers
    before Spring Boot 3.1
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  34. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  35. © VMware, Inc. 35
    Integration Tests with
    Testcontainers with Spring
    Boot 3.1
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  36. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  37. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  38. © VMware, Inc. 38
    How-to: Use Generic
    Containers / Custom Images
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  39. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  40. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  41. © VMware, Inc. 41
    Testcontainers at
    Development Time
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  42. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  43. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  44. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  45. © VMware, Inc.
    Run the Test Main Methods
    • From the IDE
    • Gradle: ./gradlew bootTestRun
    • Maven: ./mvnw spring-boot:test-run
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  46. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  47. © VMware, Inc. 47
    Why Two Main Methods?
    Why Not Reuse the Existing
    One?
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  48. © VMware, Inc. 48
    How-to: Share Container
    Declarations
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  49. © VMware, Inc.
    Share Container Declarations Between Test-main and Tests
    Extract containers into an interface
    Import this interface with @ImportTestcontainers
    • On the test-main class
    • On the tests
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  50. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  51. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  52. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  53. © VMware, Inc. 53
    Reusable Containers
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  54. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  55. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  56. © VMware, Inc.
    This is an experimental Testcontainers feature!
    https://java.testcontainers.org/features/reuse/
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  57. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  58. © VMware, Inc. 58
    Conclusion
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  59. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  60. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  61. © VMware, Inc.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  62. Thank you
    https://spring.io/blog/2023/06/19/spring-boot-31-connectiondetails-abstraction
    https://spring.io/blog/2023/06/21/docker-compose-support-in-spring-boot-3-1
    https://spring.io/blog/2023/06/23/improved-testcontainers-support-in-spring-boot-3-1
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  63. Let’s continue the conversation
    Stay Connected
    Web: https://mhalbritter.github.io/
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  64. Please take
    your survey.
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide

  65. Thank You
    VMware Explore 2023 Content: Not for publication or distribution

    View Slide