Open-source project
javastacks/spring-boot-best-practice avatar
javastacks/spring-boot-best-practice

spring-boot-best-practice: a Maven multi-module reference for Spring Boot 4.x

Spring Boot 最佳实践,已适配 Spring Boot 4.x,包括自动配置、核心原理、源码分析、国际化支持、调试、日志集成、热部署等。

5,113 stars1,355 forksJavaApache-2.0

At a glance

What is it?
The javastacks/spring-boot-best-practice repository collects runnable Spring Boot examples across 40+ topics, from JPA and Kafka to GraalVM and Actuator, on a Spring Boot 4.0.3 baseline. It is a study and migration reference, not a library you add as a dependency.
Who is it for?
Adopt it as a reading and migration reference if you are moving to Spring Boot 4.x or want a working sample of a specific integration such as Flyway, Jasypt or Spring Boot Admin. Do not add it as a dependency and do not treat its module layout as a template for your own service, because each module is a separate demo rather than one application.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 6 months ago.
What is it written in?
Mainly Java, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What spring-boot-best-practice actually is

This is a collection of small, self-contained Spring Boot applications, each one demonstrating a single topic. The README describes the repository as a Maven multi-module project covering core capabilities, data access, messaging middleware, operations and container deployment. The module table lists 40 entries, including spring-boot-quick-start, spring-boot-jpa, spring-boot-kafka, spring-boot-flyway, spring-boot-graalvm, spring-boot-actuator and a pair of Spring Boot Admin modules.

The audience is a Java developer who already knows Spring and wants a working example of one specific integration, or who is upgrading a codebase and wants to see how a given feature is configured on a newer baseline. The README states the repository is adapted for Spring Boot 4.x, with a current baseline of Spring Boot 4.0.3, Spring Framework 7.x and Java 21. That baseline is the main reason to read it now rather than an older sample set: most Spring Boot example repositories still sit on 3.x.

It is not a starter, not a framework and not a set of enforced conventions. Nothing in the repository layout suggests you depend on it. You clone it, open one module and read.

How the multi-module layout works and where the code flows

The root pom.xml is the parent for every module directory at the top level, and each module is its own Spring Boot application with its own main class, its own configuration and its own dependencies. That is the visible architecture: one parent aggregator, many independent children. The two starter modules, javastack-spring-boot-starter and javastack-spring-boot-starter-sample, are the exception in intent, since the first is a custom starter and the second demonstrates how a consuming application pulls it in.

The data flow inside any single module is ordinary Spring Boot. A main class starts the context, auto-configuration wires the beans, and the module's own classes show the feature under test. spring-boot-datasource is described as covering multiple data sources, Druid and JDBC or JdbcClient access. spring-boot-rest-services is described as covering RestTemplate, RestClient and WebClient as three different calling styles. spring-boot-admin-server and spring-boot-admin-client form a pair, so the client registers with the server rather than standing alone.

That pairing is the useful part of the design. A single module can be read in isolation, but the Admin pair and the starter pair only make sense together, which tells you the repository is meant to be browsed by topic rather than consumed as one build.

Running a module and checking the first startup

There is no install step for the project itself. The README says you can download the repository freely for study, and the top-level entries show a standard Maven layout, so the workflow is to open one module directory and build it. The README does not document a build command, so the repository itself is the only source for how a module is laid out. What you can verify from the top level is the aggregation point:

bash
pom.xml

That file is the parent for the modules listed beside it, including spring-boot-quick-start, spring-boot-application and spring-boot-web. Each of those directories holds its own application and its own configuration, so read the module's own files before assuming a port, a profile or a property name; the README does not state any of those per module.

For the custom starter, the README gives the two module names but not the coordinates, so read javastack-spring-boot-starter's pom.xml to get the groupId and artifactId before wiring it into javastack-spring-boot-starter-sample. The sample exists precisely to show that wiring, which is why the two directories sit next to each other at the top level.

Where this repository stops being useful

The modules are demonstrations, not production templates. A demo of Kafka integration shows how to configure a producer or consumer; it does not show retry policy, dead-letter handling or schema evolution, and the README makes no claim that it does. The same applies to spring-boot-jasypt, where the module shows configuration encryption but the README says nothing about key management or rotation.

There is a second, quieter limitation. The repository is a set of examples, so there is no single application you can deploy and no shared domain model across modules. If what you need is a runnable service skeleton with packaging, health checks and deployment already wired together, this collection will not give it to you; you would assemble that yourself from the individual modules.

The README also points to a 108-page tutorial distributed through a WeChat account, and states explicitly that it is not the latest version and is provided for reference only. Treat that as a separate artifact from the code, and do not assume the code modules and the PDF describe the same baseline.

Finally, the README does not document rollback, version pinning policy or a compatibility matrix between modules. If you need to know which module works on which Spring Boot patch release, the poms are the only source.

How it compares with Spring Initializr output

Spring Initializr generates a single project skeleton with the dependencies you select and nothing else. It gives you a build file, a main class and an empty test, and leaves every integration to you. spring-boot-best-practice is the inverse: no skeleton, but a worked example for each of 40 topics, already on Spring Boot 4.0.3 and Java 21.

The practical difference is what you do with the output. From Initializr you get a project you extend; from this repository you get code you read and copy. If you are starting a new service and know your stack, Initializr is faster because it produces exactly your dependency set. If you are unsure how a specific integration is configured on the 4.x line, this repository answers that question with a compiling module rather than a documentation snippet.

A second comparison point is the official Spring Boot reference documentation. It is authoritative and current, but it is prose and fragments. This repository is code that the author states is built around real development scenarios, which is a different kind of evidence: you can see the imports and the configuration keys rather than reading about them.

Maintenance, licence and upgrade cost

The repository is not archived. The last push was on 2026-03-09, and the most recent release listed is v3.5 from 2026-02-28. That is roughly six months before today, so the project is not dormant, but it is also not receiving daily changes; treat it as a periodically refreshed reference rather than a fast-moving codebase.

The upgrade cost sits with you, not the maintainers. Because each module is independent, upgrading means changing the parent pom.xml version and then fixing whatever breaks in the modules you actually use. Modules that track Spring's own APIs, such as spring-boot-webmvc, spring-boot-webflux and spring-boot-actuator, will move with the framework. Modules wrapping third-party libraries, such as spring-boot-knife4j, spring-boot-mybatis-plus or spring-boot-quartz, depend on those projects' own Spring Boot 4 compatibility, which this repository cannot control.

The licence is Apache-2.0, which permits commercial use and modification with the usual notice and attribution conditions. That is a permissive licence, but it is still a licence: if you copy a module into your product, keep the notice. This is not legal advice; read the LICENSE file and your own organisation's policy.

Editorial conclusion

Adopt it as a reading and migration reference if you are moving to Spring Boot 4.x or want a working sample of a specific integration such as Flyway, Jasypt or Spring Boot Admin. Do not add it as a dependency and do not treat its module layout as a template for your own service, because each module is a separate demo rather than one application. Before you copy anything, check the pom.xml of the module you care about for the exact Spring Boot version it resolves, and read that module's own configuration files rather than the root README, since the README lists topics but does not document per-module setup.

Frequently asked questions

Is Spring Boot still relevant in 2026?

The repository is built on a Spring Boot 4.0.3 baseline with Spring Framework 7.x and Java 21, which shows the framework line is still moving. The README also argues Spring Boot is the base for Spring Cloud, so it remains a prerequisite rather than a fading skill.

What are the best practices for a Spring Boot project structure according to spring-boot-best-practice?

The repository's own structure is a Maven multi-module aggregation where each topic is a separate application under one parent pom.xml. That is a study layout, not a recommendation for a single service, since the modules are independent demos rather than one deployable application.

Does spring-boot-best-practice cover @Bean and @Autowired?

The README does not name @Bean or @Autowired directly. It does list spring-boot-application for application startup and application-level basics, and spring-boot-properties for configuration binding and custom property classes, which is where bean and injection behaviour would appear.

Official sources

  1. javastacks/spring-boot-best-practice on GitHub
  2. License: Apache-2.0
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/javastacks-spring-boot-best-practice.svg)](https://hysenlabs.com/projects/javastacks-spring-boot-best-practice)