From spring-skills
Guide Spring Boot project setup, configuration, profiles, observability, and auto-configuration. Use when starting new Spring Boot projects, structuring configuration, working with profiles, troubleshooting auto-configuration, enabling virtual threads, or configuring observability.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spring-skills:spring-bootThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Core conventions for Spring Boot application setup, configuration, and runtime. Targets **Boot 4.0** (Spring Framework 7, Jakarta EE 11, Java 17+). Most guidance applies to Boot 3.2+ — version-specific features are annotated.
Core conventions for Spring Boot application setup, configuration, and runtime. Targets Boot 4.0 (Spring Framework 7, Jakarta EE 11, Java 17+). Most guidance applies to Boot 3.2+ — version-specific features are annotated.
Do NOT Load for framework-specific topics (security, data, web, testing) — use the dedicated skill instead.
Always bind configuration to typed records. Never scatter @Value across services.
@ConfigurationProperties(prefix = "app.order")
record OrderProperties(Duration timeout, int maxRetries, URI serviceUrl) {}
Enable scanning in the root application class with @ConfigurationPropertiesScan.
| Profile | Purpose | Activated by |
|---|---|---|
| (none) | Production-ready defaults | Default |
local | Local dev (Docker Compose, debug logging) | --spring.profiles.active=local |
test | Test overrides | @ActiveProfiles("test") |
@ConditionalOnPropertyWhen a property isn't taking effect, check in this order:
@ConfigurationProperties prefix and relaxed binding rulesspring.profiles.active in startup logs--debug to see property sources@ConfigurationPropertiesScan — properties class exists but is never boundBoot 3.2+ / Java 21+: Enable with a single property:
spring:
threads:
virtual:
enabled: true
This auto-applies to Tomcat, Jetty, Kafka listeners, RabbitMQ, task execution, and scheduling. No thread pool tuning needed.
Gotcha: For daemon-thread-only apps (e.g., only @Scheduled tasks), also set spring.main.keep-alive=true — otherwise the JVM exits immediately since virtual threads are daemon threads.
| Client | Use When |
|---|---|
RestClient | Synchronous HTTP calls (replaces RestTemplate) |
WebClient | Reactive / non-blocking HTTP |
@HttpExchange interfaces | Declarative HTTP APIs (Boot 4.0+: auto-configured via @ImportHttpServices) |
@Service
class OrderClient {
private final RestClient rest;
OrderClient(RestClient.Builder builder) {
this.rest = builder.baseUrl("https://orders.example.com").build();
}
}
Boot 3.x:
RestTemplatestill works but is deprecated. Migrate toRestClient— the API is similar.
Boot 4.0: Use spring-boot-starter-opentelemetry for traces, metrics, and log correlation.
Boot 3.2–3.5: Use
spring-boot-starter-actuatorwithmicrometer-tracing-bridge-otelandopentelemetry-exporter-otlpmanually.
management:
otlp:
tracing:
endpoint: http://otel-collector:4318/v1/traces
metrics:
export:
endpoint: http://otel-collector:4318/v1/metrics
observations:
annotations:
enabled: true # Enables @Observed, @Timed, @Counted
Spring auto-instruments HTTP server/client, JDBC, Kafka, and RabbitMQ. Use @Observed for custom business operations — avoid raw Micrometer APIs.
Boot 3.4+: Built-in JSON logging — no custom Logback encoder needed:
logging:
structured:
format:
console: ecs # Also: gelf, logstash
Boot 3.2–3.3: Requires a manual Logstash Logback encoder. See
references/logging-pre34.md.
Disable console logging entirely with logging.console.enabled=false (Boot 4.0+).
developmentOnly 'org.springframework.boot:spring-boot-docker-compose'
Spring auto-detects compose.yml and configures connections via @ServiceConnection. No manual spring.datasource.* needed for local dev.
@TestConfiguration(proxyBeanMethods = false)
class DevServices {
@Bean
@ServiceConnection
@RestartScope
PostgreSQLContainer<?> postgres() {
return new PostgreSQLContainer<>("postgres:17");
}
}
Run with spring-boot:test-run (Maven) or bootTestRun (Gradle). Use @ServiceConnection instead of @DynamicPropertySource — it auto-configures the connection.
When a bean isn't created, follow this path:
--debug — read the conditions evaluation report@SpringBootApplication scans from its package down. Beans in sibling/parent packages are invisible@Conditional* annotations — @ConditionalOnProperty, @ConditionalOnClass, @ConditionalOnMissingBean are the usual suspectsOnly exclude auto-configuration when you have a specific reason and a replacement:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
| Server | Use Case |
|---|---|
| Tomcat (default) | Standard servlet-based apps |
| Jetty | Alternative servlet container |
| Netty | Reactive (WebFlux), non-blocking |
Boot 4.0: Undertow was removed (lacks Servlet 6.1 support). Migrate to Tomcat or Jetty.
| Approach | Tradeoff | When |
|---|---|---|
| Virtual threads | No build impact, runtime concurrency | Java 21+, most apps |
| CDS (Class Data Sharing) | Moderate startup improvement, standard JVM | Boot 3.3+, java -Djarmode=tools extract |
| GraalVM native image | Fastest startup, longest build, reflection constraints | Serverless, CLI tools |
Boot 4.0 renamed several starters:
spring-boot-starter-web → spring-boot-starter-webmvcspring-boot-starter-aop → spring-boot-starter-aspectjspring-boot-starter-flywayUse spring-boot-starter-classic as a transitional bridge during migration.
@Value annotations spread across services instead of @ConfigurationProperties records. Makes configuration undiscoverable and unvalidatabledev, staging, qa, uat, preprod, prod. Use env vars for per-deployment values; profiles for fundamentally different behaviorspring.main.allow-bean-definition-overriding=true hides wiring errors. Fix the duplicate bean instead--debug first@ComponentScan with custom base packages bypassing root-package convention. Causes subtle scanning gapsLoad on demand for specific topics:
references/version-guide.md — Feature-to-version matrix, Boot 3.2 through 4.0references/migration-4x.md — Boot 4.0 migration: starter renames, Jackson 3, testing changes, removed featuresreferences/observability.md — Full Micrometer/OTLP configuration, custom observations, context propagationreferences/dev-services.md — Docker Compose and Testcontainers patterns, service connections, DevTools integrationProvides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.
npx claudepluginhub rynr/spring-skills --plugin spring-skills