Skip to content

Java / Spring Boot backend

A Java backend on Spring Boot, built with Gradle. The template and the other stacks are in the index. The reference repository is aise-feecheck-poc; every fact here was read from it, and the sources are linked where they are used. A repository on this stack keeps its own versions and exceptions in its CLAUDE.md and links here.

Languages and versions

Java (LTS) through the Gradle toolchain, Spring Boot, Gradle with the Kotlin DSL. Versions are never written down outside the build:

  • the build file is the truth: java.toolchain, the plugin versions, the BOMs, and the tool versions as named values (in the reference: backend/app/build.gradle.kts);
  • the dependency lock (dependencyLocking { lockAllConfigurations() }, gradle.lockfile) pins what those declarations resolve to;
  • the wrapper (gradle/wrapper/gradle-wrapper.properties) pins Gradle, and is committed.

A dependency's real version is what Gradle resolves, not what a registry or a search page reports. The reference's stack table, with where each item is fixed: README.md#stack.

Build

./gradlew build, from the repository root, is the gate: compile, spotlessCheck, Error Prone, tests, architecture rules, JaCoCo and PIT. It is always offline: no key, no network, no cost. The pre-push hook and CI run exactly this command, never a hand-picked task list, so the build file stays the one definition of green.

Deliberately outside it, each as its own Gradle task with its own source set:

  • a smoke test against a paid model API (integrationTest, needs the API key and skips without it);
  • tests that need Docker (doclingIntegrationTest, through Testcontainers).

Sources: README.md "Build", CLAUDE.md "Build and formatting".

Formatting

Spotless with google-java-format, both pinned in the build file. ./gradlew spotlessApply reformats; spotlessCheck is part of build. Enforced by the backend plugin (plugins/backend/README.md)'s hook: spotlessApply after every .java edit, and a spotlessCheck that blocks git commit when the formatting is off.

Line endings are LF, pinned by .gitattributes (* text=auto eol=lf, with *.bat CRLF and *.jar binary), so a Windows checkout with core.autocrlf=true and Spotless agree.

Linting and static analysis

Error Prone, through the net.ltgt.errorprone plugin, on every compile. No SonarQube and no Checkstyle, because Error Prone and Spotless replace them (arc42 §2.3 of the reference records it as a deliberate departure).

Architecture rules

jMolecules annotations declare the rings on each package-info.java, and ArchUnit with jmolecules-archunit enforces them in a test that runs in build. The reference uses onion rings per component (@DomainRing, @ApplicationRing, @InfrastructureRing), not the @…Layer annotations, because the layered model forbids an adapter implementing a port the domain declares. Source: CLAUDE.md "Architecture".

Tests

  • Unit: JUnit Jupiter (the version the Spring Boot BOM resolves) and AssertJ assertThat, not the JUnit assertions. Plain JUnit without a Spring context where a stub does the job.
  • Integration: a separate source set and Gradle task per external dependency, never wired into check or build. A smoke test against a real model asserts something only a real answer can satisfy, so a dead connection does not pass as good behaviour.
  • End to end: not used yet.
  • Naming: @DisplayName on every test, starting with the criterion ID ("I-4 · …"); the body is marked given / when / then.
  • Offline: everything in build.

Sources: CLAUDE.md "Tests", the patterns in docs/guides/testing.md.

Coverage and mutation

JaCoCo with a 90 % line-coverage floor per class, not as a project average (jacocoTestCoverageVerification), and PIT mutation testing with a 95 % mutationThreshold. Both run in build; the reports are build/reports/jacoco/test/html/ and build/reports/pitest/, and CI uploads them when the build fails. The Spring bootstrap and @Configuration classes are excluded from PIT: it reports false survivors there, because the context is cached across mutant runs; a configuration test asserts those seams instead. A repository names its report paths in the Gate reports key of its ## Workflow section (plugins/workflow/reference/workflow-section.md).

Accessibility and UI checks

Not used: no user interface.

Security and supply chain

  • Dependencies: the lockfile pins the resolved tree; Dependabot updates Gradle, the wrapper and the pinned actions weekly; on main, gradle/actions/dependency-submission gives GitHub the transitive tree. Sonatype Guide before adding or upgrading a dependency.
  • Wrapper: CI validates the committed wrapper jar against Gradle's published checksums.
  • Secrets: API keys come from the environment only; TruffleHog scans the history in CI.
  • Code: Aikido and /security-review through workflow:ready, with the Java, dependency and Actions classes of its security checklist (plugins/workflow/skills/ready/security-checklist.md), and its infrastructure-as-code section (plugins/workflow/skills/ready/security-checklist.md) for compose and Cloud Run.

Sources: .github/dependabot.yml, .github/workflows/build.yml.

Code review

Copilot and the claude-review workflow on every pull request; workflow:ready before it (simplify, /code-review, /security-review, Aikido); see sdlc/quality-gate.md.

CI

One build job runs the same ./gradlew build as the pre-push hook on JDK 25 (Temurin), after validating the wrapper; secret-scan runs TruffleHog. Every action is pinned to a commit SHA. No Windows job: the gate is JVM-only, and .gitattributes takes care of line endings. Source: .github/workflows/build.yml.

Local setup and hooks

  • dev-env:dev-doctor checks JDK 25, the Gradle wrapper and its exec bit, .gitattributes, core.hooksPath for the pre-push gate, and spotlessCheck; -Fix sets what it can.
  • The pre-push hook is versioned in .githooks/pre-push and runs ./gradlew build; activated per clone with git config core.hooksPath .githooks.
  • Claude Code: the backend plugin's formatting hook, and its Gradle permissions fragment (plugins/backend/fragments/gradle-permissions.json) merged into the repository's .claude/settings.json.
  • IDE: none required; the wrapper and a JDK are enough.

Claude Code support

The backend plugin (plugins/backend/README.md) (formatting hook, Gradle permissions), workflow:ready with the Machine gate and Gate reports keys, dev-env:dev-doctor. Gaps: the build-gate conventions and the stack traps below are not in a plugin yet (SPEC.md §4.5).

Gotchas

  • Spring AI 1.x does not run on Spring Boot 4. The chain is Spring AI 2.0 ⇒ Spring Boot 4.x ⇒ Spring Framework 7.0; do not downgrade to make an example compile.
  • Jackson 3: the package is tools.jackson.* and JacksonException is unchecked. Every Jackson example online is Jackson 2.
  • google-java-format deletes unreferenced imports with no opt-out: on a rename, change the usages first and add the import last.
  • Line endings: do not fix them by hand; git and Spotless then disagree and the build turns red.
  • Maven examples: many Spring examples online are Maven; translate them to Gradle.
  • Dependabot and the lockfile: in a multi-project build Dependabot does not regenerate gradle.lockfile; run ./gradlew :<project>:dependencies --write-locks on its branch.
  • PIT targetClasses needs **: a single * does not match subpackages, so PIT mutates nothing and the gate passes without having tested anything.
  • Tool versions lag the JDK: JaCoCo reads Java 25 class files from 0.8.15 on, newer than what Gradle defaults to; pin it. The PIT JUnit 5 plugin documents JUnit Platform 1.x only, so its pairing with the Platform Spring Boot brings is checked before either moves.
  • Two Gradle runs in one directory collide (in-progress-results-*.bin missing while every test passed): give parallel sessions their own worktree.

Sources: CLAUDE.md "Stack", the comments in backend/app/build.gradle.kts.