The receipt API project assembles a Boot web application with validated commands, protected endpoints and a separate JDBC transaction fixture.
Spring Boot receipt API project: build, test and inspect the limits
This lesson uses the downloadable source kit: Java 21, Spring Boot 4.0.8 and its managed Spring Framework 7 dependencies. The version is pinned for repeatable builds.
Build the supplied application
The kit includes its Maven build, source files, properties and tests. Run mvn test and mvn package with JDK 21, then start the executable jar locally. ReceiptApplication is the selected entrypoint; the standalone teaching programs are separate runnable classes.
The API uses ReceiptStore, an in-memory synchronized map that loses receipts when the process stops. JdbcReceiptLedger is a separate transaction lesson and is not silently wired as durable API storage. Replacing the repository needs a migration, repository integration tests and explicit transaction ownership.
Inspect the actual promises
GET health is public. Other requests need the fixture identity, and mutation also needs CSRF protection. The tests check valid and invalid commands, missing receipts, bounded pages, CORS and rollback. None of this implements real payment settlement, tenant accounts or a production identity provider.
The next extension is durable repository ownership and an idempotency contract for retries. A retry after a lost response can otherwise create another receipt. Do not call this learning project production-ready before persistence, identity, request limits and operational recovery have been tested.
Checked source
package in.aitrove.learning;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication
@EnableConfigurationProperties(ImportConfiguration.class)
public class ReceiptApplication {
public static void main(String[] args) { SpringApplication.run(ReceiptApplication.class, args); }
}Test the boundary
Run mvn test in the source-kit directory. All source-kit Maven tests checks the behavior described here. Java excerpts belong to the named source-kit classes; they are not independent source files unless the complete class is shown.
Costs and boundaries
The application starts a servlet server and H2 datasource, while API state remains in the in-memory store. Its source and tests expose those boundaries rather than implying a distributed service or a deployed backend.
Common Mistakes
- Do not deploy the fixture account or database configuration.
- Do not confuse the JDBC lesson with API persistence.
- A successful POST does not define an idempotency policy.
Read next
Spring MVC request validation: reject invalid commands before mutation, Spring TransactionTemplate: roll back a failed multi-row change, Spring Security filter chain: authentication, CSRF and request order, Java HTTP retry project: bounded attempts and one wait budget.
Continue with checked tenant security
Continue with Spring Boot receipt API: move from local Basic auth to tenant-scoped tokens.
Continue with checked tenant commands
Continue with Spring Boot tenant command API project: assemble the local write path.
Continue with checked upload and readiness
Continue with Spring Boot receipt import project: stage, validate and report without hiding failure.
Continue with checked Boot startup
Continue with Spring Boot project: test a versioned receipt schema before choosing deployment ownership.
Release boundary continuation
Continue with Spring Boot project: define the receipt service release boundary.
