-
1. What is a Spring Boot library?
- 1.1 The starter mental model
- 1.2 Auto-configuration vs `@Configuration`
- 1.3 Who is your user?
- 1.4 When _not_ to write a library
- 1.5 Anatomy of a starter
- 1.6 A taxonomy of libraries
- 1.7 Summary
-
2. A tour of a minimal starter
- 2.1 What this chapter builds
- 2.2 Project layout
- 2.3 The POM
- 2.4 The properties record
- 2.5 The filter
- 2.6 The auto-configuration class
- 2.7 Telling Spring Boot about the auto-configuration
- 2.8 Trying it out
- 2.9 How Spring Boot finds your starter
- 2.10 Summary
-
3. Design principles for library authors
- 3.1 Configure by exception
- 3.2 Step aside
- 3.3 Activate only when it makes sense
- 3.4 Fail loudly, fail clearly
- 3.5 Property names are public API
- 3.6 Be honest about nulls
- 3.7 Summary
-
4. Declaring auto-configuration
- 4.1 `@AutoConfiguration` vs `@Configuration`
- 4.2 The imports file
- 4.3 Registering other extension points
- 4.4 Why auto-configurations disable bean proxying
- 4.5 Ordering auto-configurations
-
5. Conditional beans
- 5.1 `@ConditionalOnClass`
- 5.2 `@ConditionalOnProperty`
- 5.3 `@ConditionalOnBooleanProperty`
- 5.4 `@ConditionalOnMissingBean`
- 5.5 `@ConditionalOnBean`
- 5.6 `@ConditionalOnWebApplication`
- 5.7 Optional integrations in one starter
- 5.8 Other conditional annotations
- 5.9 Summary
-
6. Custom conditions
- 6.1 The `Condition` interface
- 6.2 Composing conditions
- 6.3 Authoring a meta-annotation
- 6.4 Running the example
- 6.5 Configuration phases
- 6.6 Summary
-
7. `@ConfigurationProperties` with records
- 7.1 Why records
- 7.2 Grouping properties
- 7.3 `@DefaultValue` in detail
- 7.4 What the sample application shows
- 7.5 Summary
-
8. Validation and type binding
- 8.1 Validating at the binding boundary
- 8.2 Types Spring Boot binds for you
- 8.3 Naming conventions that keep the surface friendly
- 8.4 Map keys with special characters
- 8.5 Wildcard-style keys as a configuration vocabulary
- 8.6 What the sample application shows
- 8.7 Summary
-
9. Default property files inside the library
- 9.1 The mechanism
- 9.2 Precedence rules
- 9.3 Avoiding accidental overrides
- 9.4 When to use the defaults file vs `@DefaultValue`
- 9.5 Summary
-
10. IDE-friendly metadata
- 10.1 The annotation processor
- 10.2 Javadoc as descriptions
- 10.3 When the processor cannot see what you want
- 10.4 Value hints
- 10.5 Deprecating a property
- 10.6 Summary
-
11. Custom property converters
- 11.1 The Converter interface
- 11.2 Registering the converter
- 11.3 What the user sees
- 11.4 Skipping the converter with a static factory
- 11.5 Converters versus richer property types
- 11.6 A note on validation
- 11.7 Converter ordering and lookup
- 11.8 Summary
-
12. Composing configurations
- 12.1 When a flat autoconfig stops being enough
- 12.2 Nested static `@Configuration` classes
- 12.3 What nested grouping gives you
- 12.4 `@Import` for standalone configuration blocks
- 12.5 Keeping autoconfig classes small and focused
- 12.6 Summary
-
13. The customizer pattern
- 13.1 The convention
- 13.2 Building the hook
- 13.3 Why a builder?
- 13.4 The chain-of-responsibility alternative
- 13.5 Summary
-
14. Optional dependencies with `ObjectProvider`
- 14.1 Methods of `ObjectProvider`
- 14.2 `ObjectProvider` versus `@Autowired(required = false)`
- 14.3 Optional sibling libraries
- 14.4 A library-defined SPI
- 14.5 Summary
-
15. Programmatic bean wiring
- 15.1 `BeanPostProcessor`: enhancing beans you did not create
- 15.2 `BeanRegistrar`: registering N beans from configuration
- 15.3 Wiring the registrar and the post-processor
- 15.4 The two together
- 15.5 When `BeanDefinitionRegistryPostProcessor` is still the answer
- 15.6 Summary
-
16. `EnvironmentPostProcessor` and property source manipulation
- 16.1 The extension point
- 16.2 Registration
- 16.3 Profile-aware defaults
- 16.4 Watching it work
- 16.5 Choosing the slot deliberately
- 16.6 Practical considerations
- 16.7 Summary
-
17. Background work
- 17.1 Why `@PostConstruct` is the wrong hook
- 17.2 The `SmartLifecycle` API
- 17.3 Example: a queue-polling starter
- 17.4 Watching it work in an application
- 17.5 The test-context cache trap
- 17.6 Summary
-
18. `FailureAnalyzer` — turning stack traces into help
- 18.1 The extension point
- 18.2 Registration
- 18.3 Example: multiple `MessageHandler` beans
- 18.4 Before and after
- 18.5 Practical considerations
- 18.6 Summary
-
19. Testing auto-configuration
- 19.1 The starter under test
- 19.2 The shape of a runner test
- 19.3 Asserting on beans
- 19.4 Toggling properties
- 19.5 Letting the user override
- 19.6 When the context cannot start
- 19.7 Exercising `@ConditionalOnClass` with `FilteredClassLoader`
- 19.8 The web variants
- 19.9 Practical considerations
- 19.10 Summary
-
20. Shipping a test starter
- 20.1 Why a separate module
- 20.2 The production starter
- 20.3 A controllable `Clock` for tests
- 20.4 The test auto-configuration
- 20.5 An opt-in annotation: `@AutoConfigureMutableClock`
- 20.6 Slotting into `@WebMvcTest`
- 20.7 Summary
-
21. Container-backed starters
- 21.1 When to use
- 21.2 The starter under test
- 21.3 The `ConnectionDetails` abstraction
- 21.4 Authoring a `ContainerConnectionDetailsFactory`
- 21.5 Using it from a `@SpringBootTest`
- 21.6 Automatic container via opt-in
- 21.7 Samples as integration tests
- 21.8 Summary
-
22. Writing a README that gets adopted
- 22.1 The five questions every README must answer
- 22.2 What does not belong in the README
- 22.3 A worked example
- 22.4 Summary
-
23. Samples
- 23.1 Why samples?
- 23.2 One sample or many
- 23.3 Show only what is needed
- 23.4 Local overrides without leaking secrets
- 23.5 Samples that double as integration tests
- 23.6 Cross-linking samples and docs
- 23.7 Where samples live and how they build
- 23.8 Summary
-
24. Versioned reference documentation
- 24.1 What the reference docs are for
- 24.2 Why AsciiDoc
- 24.3 An automatic property reference
- 24.4 The documentation site
- 24.5 Why not Antora, and why not the Spring backend
- 24.6 Versioning by URL path
- 24.7 Canonical URLs
- 24.8 Publishing on release
- 24.9 Summary
-
25. Observability: tracing and metrics for library code
- 25.1 Documenting what you observe
- 25.2 Wrapping a unit of work in an `Observation`
- 25.3 Customising tags with `ObservationConvention`
- 25.4 Muting noisy observations with `ObservationPredicate`
- 25.5 Auto-instrumenting user beans with a `BeanPostProcessor`
- 25.6 Practical considerations
- 25.7 Summary
-
26. Custom actuator endpoints and health indicators
- 26.1 When your library should contribute to health
- 26.2 The starter under test
- 26.3 A `HealthIndicator` for backlog freshness
- 26.4 A custom `@Endpoint` for the dynamic state
- 26.5 Respecting the exposure rules
- 26.6 Sanitising the library's sensitive properties
- 26.7 Summary
-
27. Maven layout: from a single module to the three-module split
- 27.1 The single module as the default
- 27.2 Three signals to split
- 27.3 The split: parent, autoconfigure, starter, BOM
- 27.4 Variant starters
- 27.5 Web-stack variants: `common`, `webmvc`, `webflux`
- 27.6 Migrating from single-module to the split
- 27.7 Split example
- 27.8 Summary
-
28. Correctly publishing the library
- 28.1 What gets published, and what does not
- 28.2 Flatten the POM with `flatten-maven-plugin`
- 28.3 Source and Javadoc JARs
- 28.4 Pinning Maven plugin versions
- 28.5 Summary
-
29. Publishing to Maven Central
- 29.1 The Central Portal in 2026
- 29.2 POM metadata Central enforces
- 29.3 Signing artifacts with GPG
- 29.4 The `jreleaser.yml`
- 29.5 The GitHub release workflow
- 29.6 Doing your first release
- 29.7 Summary
-
30. Supporting your users
- 30.1 The first contact: issue templates
- 30.2 The `--debug` output you actually need
- 30.3 Ship a reproducer template
- 30.4 Closing the loop
- 30.5 When the report is a security issue
- 30.6 Summary
Crafting Spring Boot Starters
Design, build, test and publish auto-configuration libraries on Spring Boot
Wonder how the best Spring Boot 4 starters are written, the ones that drop into a project and just feel idiomatic? Want to give your teammates the same head start on new projects?
Crafting Spring Boot Starters shows you how, drawn from patterns proven in production libraries.
$49.50
With Coupon
$45.99
You pay
Author earns
About
About the Book
Every Spring Boot developer consumes starters. But do you know how to write one of your own?
As your team and your projects grow, so grows the need for shared code. The best way is to provide company-wide starters that all teams can use and depend upon. You can even put such a starter in the open for the whole world to benefit. But how exactly do you ensure that the library is a good Spring Boot citizen? You need to think about defaults, extension points, conditional wiring, testability, observability, documentation and so much more.
Crafting Spring Boot Starters walks you through all these things, showing how to implement them with real starters in the thirty chapters of the book.
Along the way you will learn how to:
- Design auto-configuration that activates only when it should, and stays out of the way when it shouldn't.
- Expose SPI interfaces, customizer chains, and configuration properties that hold up in real applications.
- Test starters in isolation, in slices, and against Testcontainers, including how to write a test starter of your own.
- Instrument library code with Micrometer Observation, custom actuator endpoints, and health indicators.
- Lay out a Maven build that scales from a single module to an autoconfigure + starter + BOM split.
- Publish releases through JReleaser.
- Write a README, samples folder, and reference site that turn a curious reader into an adopter.
The book is for Java developers who have shipped Spring Boot applications and now want to ship libraries. Every chapter is using patterns from real production starters, rebuilt from scratch so you can read, run, and adapt the code yourself.
The book also includes a zip file with AI skills that can be used with any AI Agent (Claude, Copilot, OpenAI Codex, ChatGPT, Cursor, ...) based on the contents of the book. The AI skills allow you to audit your own Spring Boot starter against the best practices laid out in the book.
Author
About the Author
Wim Deblauwe is a freelance Java developer who has been working mainly with Java and Spring for the past 25 years. He has developed and designed various software projects that have seen deployments worldwide. He also loves to guide and teach others about topics like Java, Spring, and Thymeleaf.
Podcast
Podcast Episode
Contents
Table of Contents
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.