@Component vs @Service vs @Repository in Spring: Differences
All three register Spring beans through component scanning. They differ in the layer they describe, and @Repository adds persistence exception translation.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
All three register Spring beans through component scanning. They differ in the layer they describe, and @Repository adds persistence exception translation.
Register Spring beans with @Configuration and @Bean methods, wire dependencies, choose scopes and lifecycle callbacks, and resolve ambiguity with @Primary and @Qualifier.
ApplicationContext is the central Spring container that wires beans, handles lifecycle, events, profiles and messages. Learn its implementations, lifecycle and best practices.
Spring instantiates, injects, initializes and destroys beans in a fixed order. Learn the lifecycle callbacks, their order, and how scopes change destruction.
Step by step guide to a new Spring Boot project: generate it with Spring Initializr, write a REST endpoint, run and package it, configure profiles and add a test.
It is a composite annotation that turns your main class into a configuration source, enables auto-configuration and scans your packages for components.
Build a reusable Spring Boot starter with @AutoConfiguration, conditional beans and the AutoConfiguration.imports file that replaced spring.factories.
spring.profiles.active chooses which Spring Boot profile config and beans load. See how to set the prod profile safely through environment variables and arguments.
A practical production checklist for Spring Boot 3.x: profiles, secrets, schema validation, connection pooling, Actuator, logging and JVM tuning.
The spring.devtools.restart.enabled property controls automatic restart in Spring Boot DevTools. See its default value, how it works and how to disable or tune it.
Add spring-boot-devtools as a development-only dependency to get automatic restarts, LiveReload and development defaults. Learn the key properties and common problems.
The Health class holds the status and details of one health check in Spring Boot Actuator, and the health endpoint aggregates it into the app status.
Implement HealthIndicator in Spring Boot 3, return UP or DOWN with details, and configure health groups for liveness and readiness probes.
This property is the allow-list for Spring Boot Actuator web endpoints. Learn the default of health only, how to use include and exclude, and how to secure endpoints.
Add the Actuator starter and expose the endpoints you need with a single property, then secure them and optionally move them to a private port.
HealthIndicator defines a custom health check in Spring Boot Actuator. See how to implement it, set statuses, expose details and use liveness and readiness groups.
Set up the Spring Boot Actuator health endpoint, write a custom HealthIndicator and configure liveness and readiness probes for Kubernetes.
@PropertySource loads extra properties files into the Spring Environment. See usage, precedence, YAML support and the Spring Boot alternatives.
Learn how Spring Boot merges property sources, binds them with @ConfigurationProperties, and lets one JAR run in every environment.
How spring.profiles.active chooses Spring profiles, the ways to set it, profile-specific files, @Profile beans, groups and @ActiveProfiles in tests.