Index of every page on this site: llms.txt
All skills
github avatar

/java-springboot

@f10fdb8 official
by githubgithub/awesome-copilot42k stars
5,426
Run it yourself

Write and review application code in an existing Spring Boot 3/4 project: controllers, validation and ProblemDetail errors, Spring Data JPA/JDBC, RestClient and HTTP interfaces, configuration properties, Kafka/AMQP, caching, scheduling, virtual threads, AOT and startup tuning. Use when adding or changing features. To scaffold a new project use create-spring-boot-java-project instead.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/java-springboot

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesaot-and-startup.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

AOT, CDS and startup

Start with measurement, not flags: record startup time (Started ... in N seconds log, or spring.main.log-startup-info=true) and memory on the target hardware before and after each change, with several runs (single timings are noisy: observed differences between runs of the same configuration were larger than some of the gains). Do not change JVM or Spring flags without a stated goal (startup, memory, image size). Verified on Boot 4.1.1, Maven, JDK 26 runtime (--release 25); JDK 21 and 25 were not available for these runs.

Spring AOT (build-time processing)

Spring AOT turns bean definitions and reflection/proxy hints into generated code. It is required for GraalVM native images and optional on the JVM.

./mvnw -DskipTests package spring-boot:process-aot    # Gradle: ./gradlew processAot

Verified: on the sample app (JPA, Flyway, Kafka, cache, validation, springdoc) process-aot succeeded and generated sources under target/spring-aot/main/sources/ (for example DemoApplication__BeanDefinitions.java). Notes:

  • AOT evaluates conditions and bean definitions at build time: profiles and properties that change the bean graph (@Profile, @ConditionalOnProperty) are fixed at build time. Do not rely on runtime-only conditions.
  • process-aot starts the application context without connecting your beans to real services; if it fails, the usual causes are beans with runtime-only side effects in constructors or an ambiguous main class (set <start-class> in Maven, see create-spring-boot-java-project references/spring-boot-4.md).
  • Custom reflection/resources: register hints with @ImportRuntimeHints and RuntimeHintsRegistrar, or @RegisterReflectionForBinding for DTOs serialized by Jackson.
  • Using the generated code on the JVM requires running with -Dspring.aot.enabled=true and packaging the AOT output; that path was not verified here and gives modest gains, so prefer CDS/AOT cache below for JVM startup.

Native image

For a native executable use the java-add-graalvm-native-image-support skill (build tool detection, native build, error iteration) and the native Dockerfiles of create-spring-boot-java-project (references/docker.md). Trade-offs: much faster startup and lower memory, but slower builds, closed-world assumptions (reflection hints), and some libraries need extra hints. Not verified in this skill.

Class Data Sharing (CDS) / Application CDS

Spring Boot supports CDS through the extracted jar layout (-Djarmode=tools). Verified sequence on Boot 4.1.1 (the training run needs the app's dependencies, here a PostgreSQL):

./mvnw -DskipTests package
java -Djarmode=tools -jar target/app.jar extract --destination extracted
cd extracted
# training run: create the archive on exit (the app exits right after context refresh)
java -XX:ArchiveClassesAtExit=app.jsa -Dspring.context.exit=onRefresh -jar app.jar
# production run
java -XX:SharedArchiveFile=app.jsa -jar app.jar

Verified: app.jsa (about 50 MB for the sample app) was created and used without errors. The [warning][cds] Skipping ... Failed verification and NoClassDefFoundError preload warnings in the training run concern optional classes whose libraries are not on the classpath (reactor, Apache HttpClient, Log4j) and are harmless. The archive is tied to the exact JVM and jar: regenerate it in the build or image build for each version, and run the training with the same JDK as production.

JDK 19+ can also create the archive automatically at the first run (-XX:+AutoCreateSharedArchive -XX:SharedArchiveFile=app.jsa; verified that the file is created).

JDK 25+ one-step AOT cache (JEP 514): java -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -jar app.jar, then java -XX:AOTCache=app.aot -jar app.jar. Verified on JDK 26 (about 160 MB cache, used without errors). JDK 24 introduced AOT caches (JEP 483) but requires separate AOTMode=record and AOTMode=create steps; it does not recognize AOTCacheOutput. Check java -version before choosing the command, and keep CDS as the fallback for older JDKs. Same rule: one cache per JDK build and jar.

In containers, create the archive during docker build (a RUN training step in the final stage) rather than at container start.

Lazy initialization

spring.main.lazy-initialization=true
  • Defers bean creation to first use, which lowers startup time and memory at start but moves failures and the first-request latency to runtime: misconfigured beans no longer fail fast, and health checks may pass on a half-working app. Use it for dev/test or short-lived processes; avoid it as a production default. Set @Lazy(false) on beans that must start eagerly (schedulers, listeners).
  • Measured on the sample app: no consistent startup gain over several runs; do not promise one.

Other cheap wins

  • Remove unused starters and auto-configurations; --debug prints the condition evaluation report to find what starts.
  • spring.jpa.open-in-view=false and spring.main.banner-mode=off cost nothing.
  • Set -XX:TieredStopAtLevel=1 only for short-lived CLI-style jobs; it hurts steady-state throughput.
  • Container memory: let the JVM size heap from container limits (-XX:MaxRAMPercentage); do not hard-code -Xmx equal to the limit.
  • Virtual threads do not change startup (references/messaging-caching.md).

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning5d5 checks · Risk SAFE
  • Gen Agent Trust Hub12d

    The skill provides safe and idiomatic guidance for Spring Boot 3 and 4 development. It incorporates several security best practices, such as proper secret management (advising against committing credentials), input validation, and secure API design. A minor risk factor is present as the agent is instructed to read external project build and configuration files, which could theoretically contain malicious instructions designed to influence the agent.

  • Socket5d

    No alerts

  • Snyk12d

    Risk: LOW · No issues

  • Runlayer9mo

    1/1 file flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated last month
  • Testing
  • java
  • spring-boot
  • rest-api
  • jpa
  • spring-security
  • configuration
  • dependency-injection

README badge

README badge for github/awesome-copilot/java-springboot

Instructs Claude to follow Spring Boot best practices for Java applications, covering project structure, dependency injection, configuration management, REST API design, data access patterns, testing, and security. Targets developers building Spring Boot applications with Maven or Gradle and using Spring Data JPA for persistence.

Generated from the current SKILL.md.

Does this skill cover Spring Security configuration?
Yes. It includes guidance on using Spring Security for authentication and authorization, password encoding with BCrypt, and preventing SQL injection and XSS attacks.
What testing frameworks does this skill recommend?
JUnit 5 and Mockito for unit tests, @SpringBootTest for integration tests, test slice annotations like @WebMvcTest and @DataJpaTest for isolated testing, and Testcontainers for reliable database and external service testing.
Does this skill cover data layer patterns?
Yes. It covers Spring Data JPA repositories, custom queries with @Query, the JPA Criteria API, and DTO projections for efficient data fetching.
What configuration approach does this skill recommend?
Use externalized configuration via application.yml, @ConfigurationProperties for type-safe binding, Spring Profiles for environment-specific configs, and environment variables or secret management tools like Vault or AWS Secrets Manager for secrets.
Does this skill address error handling?
Yes. It recommends implementing a global exception handler using @ControllerAdvice and @ExceptionHandler for consistent error responses across the application.

Generated from the current SKILL.md. These answers refresh after source changes.