Java and Spring Boot checklist¶
Copy this list into a pull request, design review or project kickoff and tick what applies. Rules are grouped by level and sorted by score (criteria). Each links to the file that explains it and cites its sources. Automatable names tools that can check the rule in CI (see the file's "How to enforce" section).
Also apply the general checklist.
This file is generated by python3 scripts/rank.py fix from the guidelines. Don't edit it by hand.
Strongly recommended (9–10)¶
-
SPRING-3(9) Keep secrets out ofapplication.properties,application.yamland every other file in the repository: mount them as files and import them withspring.config.import=configtree:, or load them from a secrets manager, for example with Spring Cloud Vault. (specific/spring-boot) Automatable: GitHub secret scanning push protection. -
SPRING-5(9) Declare the authorization of every request in eachSecurityFilterChain: permit the public paths explicitly, require roles or authorities for the rest, and end withanyRequest().authenticated()oranyRequest().denyAll(). (specific/spring-boot) -
SPRING-6(9) Expose only the Actuator endpoints you need over HTTP, and secure every exposed endpoint other thanhealth, with Spring Security rules built onEndpointRequestor by keeping the endpoints behind a firewall. (specific/spring-boot) Automatable: CodeQL, Disabled Spring CSRF protection.
Recommended (6–8)¶
-
SPRING-7(8) Keep Spring Security's CSRF protection, which is on by default, for every endpoint that browsers call with cookies or HTTP Basic credentials, and exempt only paths that only non-browser clients call, such as APIs authenticated with bearer tokens, withcsrf.ignoringRequestMatchers()instead of turning the protection off withcsrf.disable(). (specific/spring-boot) Automatable: CodeQL, Disabled Spring CSRF protection. -
SPRING-9(8) Manage the schema with Flyway or Liquibase migrations, which Spring Boot runs at startup, and leavespring.jpa.hibernate.ddl-autoatnoneor set it tovalidate. (specific/spring-boot) -
SPRING-14(8) Run a Spring Boot generation that still has open-source support, and upgrade to the next minor release before its support ends; run it on a Java LTS release that your JDK distribution still updates. (specific/spring-boot) Automatable: OWASP Dependency-Check. -
SPRING-1(7) Inject dependencies through constructors, not into fields. (specific/spring-boot) Automatable: ArchUnit GeneralCodingRules. -
SPRING-8(7) Use method security (@EnableMethodSecuritywith@PreAuthorizeand@PostAuthorize) for checks that depend on a method's arguments or return value, such as ownership of a record, and keep a catch-all rule in theSecurityFilterChain. (specific/spring-boot) -
SPRING-10(7) Map every association withfetch = LAZY, fetch the data each use case needs up front withjoin fetchor an entity graph (@EntityGraphin Spring Data JPA), and setspring.jpa.open-in-view=false. (specific/spring-boot) -
SPRING-11(7) Define transaction boundaries with@Transactionalon the methods of service classes that carry out one use case across several repository calls, and call those methods from other beans. (specific/spring-boot) Automatable: ArchUnit GeneralCodingRules. -
SPRING-12(7) On Kubernetes, point the liveness and readiness probes at/actuator/health/livenessand/actuator/health/readiness, keep checks of external systems out of the liveness group, and give the pod apreStopsleep and a termination grace period long enough for the sleep andspring.lifecycle.timeout-per-shutdown-phase. (specific/spring-boot) -
SPRING-13(7) Instrument through Micrometer Observation, which Spring Boot uses for metrics and traces, export both over OTLP to an OpenTelemetry Collector, and set the service name withOTEL_SERVICE_NAMEormanagement.opentelemetry.resource-attributes. (specific/spring-boot) -
SPRING-16(7) Test controllers with@WebMvcTestand repositories with@DataJpaTest, and run at least the repository and integration tests against the database engine you use in production, started by Testcontainers and connected with@ServiceConnection. (specific/spring-boot) -
SPRING-2(6) Package by feature: put the main application class in a root package, give each business capability its own subpackage, and once there are several, enforce the boundaries with Spring Modulith. (specific/spring-boot) Automatable: Spring Modulith verification. -
SPRING-4(6) Bind your own settings to@ConfigurationPropertiesclasses instead of scattering@Valueannotations, and annotate them with@Validatedand Jakarta Bean Validation constraints, so that Spring Boot validates the values when it binds them. (specific/spring-boot)
Conditional (1–5)¶
-
SPRING-15(5) Enable virtual threads withspring.threads.virtual.enabled=trueonly on Java 21 or later, preferably Java 24 or later, and when you do, setspring.main.keep-alive=trueand limit concurrency with semaphores or connection pools rather than pools of threads. (specific/spring-boot)