Spring Boot starters Starters are curated dependency descriptors: a single dependency that brings in a consistent, compatible set of libraries for a particular capability, along with the auto-configuration that sets them up. Examples - spring-boot-starter-web: Spring MVC, embedded Tomcat, Jackson for JSON, validation support. - spring-boot-starter-webflux: reactive web stack with Netty. - spring-boot-starter-data-jpa: Spring Data JPA, Hibernate, HikariCP. - spring-boot-starter-security: Spring Security. - spring-boot-starter-oauth2-resource-server: JWT and OAuth2 resource server support. - spring-boot-starter-validation: Bean Validation with Hibernate Validator. - spring-boot-starter-actuator: production monitoring features. - spring-boot-starter-test: JUnit 5, Mockito, AssertJ, Spring Test, JSONassert. - spring-boot-starter-data-redis, -amqp, -cache, and many more. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> Benefits - No need to find and align versions of many libraries; the Spring Boot parent or BOM manages versions so they are tested together. - Fewer dependency conflicts and faster project setup (start.spring.io generates projects with chosen starters). - Naming convention: official starters are spring-boot-starter-*; third-party starters use name-spring-boot-starter. Spring Boot Actuator Actuator adds production-ready features to monitor and manage a running application through HTTP endpoints or JMX. Common endpoints - /actuator/health: application health, including database, disk space, message brokers and custom checks; health groups for Kubernetes liveness and readiness probes (/actuator/health/liveness, /actuator/health/readiness). - /actuator/info: build and Git information, application metadata. - /actuator/metrics: JVM, HTTP request, database pool and custom metrics through Micrometer. - /actuator/prometheus: metrics in Prometheus format (with micrometer-registry-prometheus). - /actuator/loggers: view and change log levels at runtime. - /actuator/env and /actuator/configprops: configuration details (sensitive; values are sanitised by default). - /actuator/mappings, /actuator/beans, /actuator/conditions: request mappings, beans and auto-configuration report. - /actuator/threaddump and /actuator/heapdump: diagnostics (very sensitive). Configuration management.endpoints.web.exposure.include=health,info,metrics,prometheus management.endpoint.health.probes.enabled=true management.endpoint.health.show-details=when-authorized management.server.port=8081 Custom health indicator @Component class PaymentGatewayHealth implements HealthIndicator { public Health health() { return gatewayClient.ping() ? Health.up().build() : Health.down().withDetail("gateway", "unreachable").build(); } } Security best practices - Expose only the endpoints you need (by default only health is exposed over HTTP). - Protect Actuator endpoints with Spring Security, or run them on a separate management port not exposed publicly. - Never expose heapdump, env or threaddump publicly — they can leak secrets and sensitive data. Observability Actuator integrates with Micrometer for metrics and Micrometer Tracing (OpenTelemetry) for distributed tracing, feeding Prometheus, Grafana and APM tools. Interview summary: "Starters are dependency bundles that pull in compatible libraries and trigger auto-configuration for a feature. Actuator provides production endpoints for health, metrics, info, loggers and diagnostics, used for monitoring and Kubernetes probes — and must be secured carefully."
Ravindra Wadile · · 0 likes