Spring BootJava 21Spring Framework深入淺出

Spring Boot, step by step: understand a request and verify a change

··5 min read

You can read Java and still be unsure who creates a controller, where configuration enters, or which operations a transaction covers. This course follows one ticket API and adds one boundary at a time, so annotations connect to observable behavior.

Continue with the independent JBoss EAP series: foundations and practical work

Prerequisites: enough Java to follow the code

You need classes, constructors, interfaces, exceptions, and basic generics. A record is a concise data carrier with accessors and value-oriented methods; this lab reads ticket.id(). HTTP methods, status codes, and JSON are introduced along the way. No prior Spring, Hibernate, or EAP knowledge is assumed, and the IDE is your choice.

The course pins Java 21 and Boot 3.5.16 to match the migration target, not to claim the newest release. Do not copy Boot 4 starters, test imports, or Servlet assumptions into this project without checking. Sources were checked on October 4, 2026; executed lab checks are recorded in the download’s VALIDATION.md.

Open-source support for Spring Boot 3.5 ended on 2026-06-30; 3.5.16 is the last open-source release. Commercial support runs until 2032-06-30, according to the third-party site endoflife.date (listed as VMware commercial support).

Six lessons, each ending in a question you can answer

LessonExplain this afterwardsWhere to look
01 StartupHow main becomes an HTTP applicationpom.xml, LabApplication
02 ObjectsWho creates services and supplies dependenciesController/service constructors
03 ConfigurationWhich value wins when a key appears three timesLabProperties, properties files
04 HTTPHow JSON reaches a method; where 400/404 are chosenCreateTicket, ApiErrors
05 TransactionsWhether the first insert rolls back after a later failureTicketStore, createBatch
06 EvidenceWhat each test proves; how JAR and WAR differLabIntegrationTest, packaged artifact
Read in order or jump to the boundary you need.
01: Startup and the first API02: Beans, injection, auto-configuration03: Configuration and profiles04: HTTP, validation, error contracts05: Database and transaction rollback06: Tests, debugging, deployment boundaries
On the left, top to bottom, are the parts of the ticket API: LabApplication and pom.xml, an HTTP request into TicketController (CreateTicket, with errors going to ApiErrors), TicketService, TicketStore and H2, and LabProperties. On the right, each part is tagged with its lesson: 01 startup, 04 HTTP, 02 objects, 05 transactions, 03 configuration. The outer frame is 06 verification: LabIntegrationTest, JAR, and WAR. An arrow at the bottom points to the JBoss EAP series
Which part of the ticket API each lesson opens. Class names come from the series download and the lesson table above. Diagram drawn by KeepOnFirst.

One ticket travels through HTTP and a database

text
HTTP → TicketController → TicketService → TicketStore → H2
                      ↘ ApiErrors → HTTP error response

The download is one complete small project, not six incompatible snippets. Start with startup and ping, then open the other classes later. A ticket has only id and title. In-memory H2 and JDBC make SQL, commit, and rollback visible without DB2, MQ, or corporate business data.

This learning application binds to loopback and has no login. It does not implement production authorization, auditing, persistent-schema migration, or deployment configuration. Running the lab is not evidence of production readiness. JPA/Hibernate and Spring Security require separate exercises; this course identifies where they fit.

Predict, run, and compare the evidence

Read the question and a small code sample, predict the result, and then run the exercise. Answers follow the exercise so you can pause before checking. When stuck, follow one path: did JSON parsing, validation, or service logic cause the 400? You do not need a whole-repository explanation or notes on every line.

A useful prompt is: “Using only these three files, explain the entry point, object ownership, and failure branch, and identify what the files cannot establish.” Try recalling the path the next day. Pointing to code and tests distinguishes project understanding from a generic summary.

How this series was checked

The shared ticket API example was checked on 4 October 2026. The setup was macOS (ARM64), Temurin OpenJDK 21.0.9, Maven 3.9.12, and Spring Boot 3.5.16.

Build: mvn package succeeded. All 8 tests passed, with no failures and none skipped.

Real HTTP: the packaged JAR was started, and real HTTP requests were sent from the local machine. The checks covered ping, create and read, a blank title, broken JSON, a title that is too long, and an id that does not exist.

Configuration: one value was overridden by the properties file, the local profile, an environment variable, and a command-line argument, in that order. Each layer gave the expected value. With the title length limit set to 0, the app refused to start.

Deliberate breakage: in a separate scratch copy, removing @Repository stopped the app from starting. Removing @Transactional made the rollback test fail (expected 0 rows, got 1). The download keeps both annotations.

Web pages: all 7 articles in both languages were checked at desktop (1440 × 1000) and phone (390 × 844) sizes. There were no page errors and no horizontal scrolling. With JavaScript off, all 14 pages still showed the text and the series links. The download includes VALIDATION.md and verify_http.py, so you can run the checks yourself. The first Maven run downloads dependencies.

Not checked: DB2, Hibernate/JPA, MQ, deployment to EAP, login and permissions, concurrency and load, production data, or old-versus-new behavior. Passing on H2 does not mean DB2 compatibility. The example binds to the local address only and has no security layer. Do not expose it to the internet. WAR packaging and an embedded Tomcat start were checked separately in Lesson 08 of the EAP series.

After Spring Boot: EAP and JBoss

The next stage starts with application-server responsibilities: WAR/EAR deployment, module loading, JNDI, data sources, EJB/MDB, transactions, and management logs. JBoss is a product-family and historical name; JBoss EAP is Red Hat’s enterprise application platform. Learn the application first, then identify the responsibilities its external container takes over.

For the broader migration, open the EAP × Boot guideDownload the complete ticket API lab (ZIP)Next: 01: Startup and the first API

Sources