Generated banner for Java Springboot
Generated logo for Java Springboot

Java Springboot

GitHubOfficialFirst committed by jduboisDistributed by GitHub

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

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.
— the description by jdubois

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides rules and best practices for developing features within an established Spring Boot 3 or 4 project. It covers essential areas including configuration management, data access, REST API design, messaging, and startup optimization. The skill emphasizes maintaining consistency with existing project conventions, verifying changes through the project's build system, and avoiding implicit upgrades or unauthorized infrastructure additions.

What it does

  • Provides guidance on implementing controllers, validation, and ProblemDetail error handling.
  • Offers patterns for Spring Data JPA/JDBC, RestClient, and HTTP interfaces.
  • Details configuration management using type-safe properties and profiles.
  • Covers integration of messaging systems like Kafka and AMQP, caching, and scheduling.
  • Explains startup tuning techniques including AOT, CDS, and virtual threads.
  • Enforces strict adherence to existing project build tools and versioning conventions.

When to use it

  • When you need to add new features or modify existing code in a Spring Boot 3 or 4 project.
  • When implementing new configuration properties or managing environment-specific settings.
  • When optimizing application startup times or memory usage using AOT or CDS.
  • When integrating new messaging, caching, or database components into an existing codebase.

Advantages

  • Ensures consistency by matching existing project structure, versions, and naming conventions.
  • Promotes safe development practices by requiring build verification before finalizing changes.
  • Provides clear guidance on modern Spring Boot features like virtual threads and AOT.
  • Reduces configuration errors through type-safe property binding and validation.

Usage examples

“How do I add a new configuration property for my mail service in my Spring Boot 4 project?”
The agent will provide a code snippet for a type-safe record using @ConfigurationProperties and explain how to register it using @ConfigurationPropertiesScan.
“I need to implement a REST endpoint that returns a custom error using ProblemDetail.”
The agent will guide you to create a @RestControllerAdvice and demonstrate how to map exceptions to the RFC 7807 ProblemDetail format.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/github/java-springboot/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip java-springboot.zip -d .agents/skills

Documentation by jdubois

Spring Boot application development

Opinionated rules plus a router to deeper references. Code samples in the references were compiled and run on Spring Boot 4.1.1 (Spring Framework 7) and, where they differ, on Boot 3.5.16 (Framework 6.2). Boot 3 vs 4 differences are marked "Boot 3" / "Boot 4" in each reference.

Before writing code

  1. Detect, do not assume: read pom.xml/build.gradle(.kts) for the Spring Boot version, Java version, starters in use (spring-boot-starter-web is Boot 3, spring-boot-starter-webmvc is Boot 4), persistence (JPA, JDBC), the migration tool, the test setup, and the package layout and naming conventions of the existing code. Match them.

  2. Never upgrade Spring Boot, Java or dependencies implicitly. A Boot 3 -> 4 move is a deliberate task (spring-boot-4-migration).

  3. Ask before adding infrastructure: a broker (Kafka, RabbitMQ), a cache provider, a new database, or a scheduler/async setup. Add only what the user requested, with the Boot-managed version (no explicit version for BOM-managed artifacts, never latest).

  4. Verify every change with the project's own build: ./mvnw verify or ./gradlew build (plain mvn/gradle if no wrapper). Integration tests need Docker when they use Testcontainers.

Router

TaskRead
Repositories, projections, pagination, N+1, @Transactional, auditing, Flyway/Liquibase, Spring Data JDBCreferences/data.md
Controllers, validation, ProblemDetail, RestClient, @HttpExchange, API versioning, OpenAPI, JSpecifyreferences/rest-api.md
Kafka/AMQP, @Cacheable/Caffeine, @Scheduled, @Async, virtual threads, outboxreferences/messaging-caching.md
@ConfigurationProperties, profiles, secrets, config import, Docker Compose / Testcontainers at dev timereferences/configuration.md
AOT, CDS/AppCDS, lazy initialization, native imagereferences/aot-and-startup.md

If these standalone skills are installed, also use them for their topic; otherwise rely on the official docs: java-hibernate-jpa (JPA mapping), spring-boot-testing (tests), spring-security (authentication, authorization, CSRF/CORS), spring-observability (metrics, tracing, Actuator, logs), create-spring-boot-java-project (project defaults, Boot 3 vs 4 build changes), java-add-graalvm-native-image-support (native executable).

Core rules

  • Structure and layers: package by feature; constructor injection; controllers return DTOs/records, never entities; services own the transaction.

  • Validation and errors: Bean Validation on request records with @Valid; one @RestControllerAdvice returning ProblemDetail. JSpecify annotations document nullability only and do not validate.

  • Jackson: Boot 4 uses Jackson 3 (tools.jackson.databind.*, JsonMapper; annotations stay in com.fasterxml.jackson.annotation); Boot 3 uses Jackson 2 (com.fasterxml.jackson.databind.*, ObjectMapper).

  • Slice-test gotcha: put @EnableJpaAuditing, @EnableCaching, @EnableAsync, @EnableScheduling on dedicated @Configuration classes, not on the @SpringBootApplication class, or slices such as @DataJpaTest fail to start (for example, no CacheManager). Slices do not scan @Configuration classes: @Import the one a test needs.

  • Proxied beans: @Cacheable, @Async and @Transactional work through proxies: they do nothing on self-invocation or on private/final methods; test them through the injected bean.

Checklist

  • [ ] Versions, build tool and conventions detected; starters match the Boot major

  • [ ] No new infrastructure or dependency without the user's agreement

  • [ ] ./mvnw verify / ./gradlew build passes; secrets absent from code, properties and logs

See also: Spring Boot reference https://docs.spring.io/spring-boot/reference/, Spring Framework reference https://docs.spring.io/spring-framework/reference/, Spring Data https://docs.spring.io/spring-data/commons/reference/.

Files

references/data.md

Data access (Spring Data JPA, Spring Data JDBC)

For mapping problems (N+1 theory, equals/hashCode, cascades, locking, batching) use the java-hibernate-jpa skill; for PostgreSQL defaults and Docker Compose use create-spring-boot-java-project (references/database.md); for @DataJpaTest and Testcontainers use spring-boot-testing. This file covers the Spring layer on top. Verified with Spring Data JPA on Boot 4.1.1 and Boot 3.5.16 (same code).

Repositories

public interface OrderRepository extends JpaRepository<PurchaseOrder, Long> {

	interface CustomerView { Long getId(); String getCustomer(); }   // interface projection

	Page<CustomerView> findByStatus(PurchaseOrder.Status status, Pageable pageable);

	@Query("select new com.example.demo.OrderSummary(o.id, o.customer, o.total) from PurchaseOrder o where o.customer = :customer")
	Page<OrderSummary> summaries(String customer, Pageable pageable);   // record DTO

	@EntityGraph(attributePaths = "items")
	Optional<PurchaseOrder> findWithItemsById(Long id);                 // fetches the collection in one query
}
  • Derived queries for simple lookups; @Query (JPQL) once the method name gets long; @Query(nativeQuery = true) only when JPQL cannot express it. Named parameters (:customer) bind by name when compiled with -parameters (the Boot parent POM and Gradle plugin enable it; verified without @Param).

  • Projections: return interface projections (closed: only getters for the needed columns) or record DTOs (select new ... with the fully qualified name) for read endpoints.

  • Pagination: Page<T> runs an extra count query; use Slice<T> when the total is not needed. Always sort on a stable, unique column (Sort.by("id")); cap the page size from user input (Math.min(size, 100)). Never combine pagination with a collection JOIN FETCH (in-memory paging; see java-hibernate-jpa).

  • N+1: fix per query with @EntityGraph or JOIN FETCH, keep associations LAZY, and assert statement counts in a test (hibernate.generate_statistics).

  • spring.jpa.open-in-view=false; load what the response needs inside the transaction and map to DTOs there.

  • Boot 4: JPA slice classes moved: org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest, org.springframework.boot.jpa.test.autoconfigure.TestEntityManager, org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabase (Boot 3: org.springframework.boot.test.autoconfigure.orm.jpa.* and ...autoconfigure.jdbc.*). Starter: spring-boot-starter-data-jpa (+ spring-boot-starter-data-jpa-test for tests).

Transactions

  • @Transactional on service methods (the use-case boundary), not on controllers or repositories. Reads: @Transactional(readOnly = true).

  • Keep transactions short: no HTTP calls, messaging sends or file I/O inside; publish events after commit with @TransactionalEventListener(phase = AFTER_COMMIT) or an outbox (references/messaging-caching.md).

  • Spring rolls back on unchecked exceptions only; use rollbackFor for checked ones. Self-invocation bypasses the proxy.

  • Services return DTOs, so lazy associations are never touched after the transaction ends.

Auditing

@Configuration(proxyBeanMethods = false)
@EnableJpaAuditing
class JpaAuditingConfig {}   // not on the @SpringBootApplication class

@Entity @EntityListeners(AuditingEntityListener.class)
class PurchaseOrder {
	@CreatedDate Instant createdAt;
	@LastModifiedDate Instant lastModifiedAt;
}

@DataJpaTest does not scan @Configuration classes: @Import(JpaAuditingConfig.class) in the test, otherwise createdAt stays null (verified). For @CreatedBy/@LastModifiedBy provide an AuditorAware<String> bean (usually from the security context; see spring-security).

Schema management

Follow the schema management rule of java-hibernate-jpa (prototype: update; production: Flyway/Liquibase with ddl-auto=validate; externally managed: none). With Spring Boot:

  • Boot 4: add spring-boot-starter-flyway (and org.flywaydb:flyway-database-postgresql for PostgreSQL) or spring-boot-starter-liquibase; the auto-configuration lives in the starter. Boot 3: org.flywaydb:flyway-core (+ flyway-database-postgresql) or liquibase-core.

  • Migrations in src/main/resources/db/migration/V1__init.sql; never edit an applied migration, add a new version. Each migration is one reviewable unit; use ddl-auto=validate so entity/schema drift fails at startup (verified: a Flyway-created schema passes validate for the entities above).

  • Add them only when the user wants versioned migrations or the app is headed to production; do not add Flyway to a project whose schema is managed elsewhere.

Spring Data JDBC (alternative)

Choose it for simple aggregates without lazy loading, sessions or dirty tracking: aggregate roots are loaded and saved as a whole, and there is no persistence context. Starter spring-boot-starter-data-jdbc (do not put it next to data-jpa in the same module unless you configure repository scanning explicitly: both would try to claim repositories).

public record Book(@Id Long id, String title, @MappedCollection(idColumn = "book") Set<Chapter> chapters) {
	public record Chapter(String name) {}
}

public interface BookRepository extends ListCrudRepository<Book, Long>, PagingAndSortingRepository<Book, Long> {
	List<Book> findByTitleStartingWith(String prefix);
}
  • You own the schema (schema.sql with spring.sql.init.mode=always, or Flyway/Liquibase as above); there is no ddl-auto.

  • null id means insert; the saved copy carries the generated id (repo.save returns it: use the return value with records).

  • Boot 4 test slice: org.springframework.boot.data.jdbc.test.autoconfigure.DataJdbcTest (verified with a Testcontainers PostgreSQL, @AutoConfigureTestDatabase(replace = NONE)).

  • Not a drop-in for JPA: no @EntityGraph, no lazy associations, references between aggregates are by id.

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of jduboisjdubois
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/java-springboot · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
jdubois

AutoGineer is not affiliated with or endorsed by jdubois or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download java-springboot.zip