▶Spring Boot vs raw Spring Framework — why choose Boot?
Spring Framework is the foundation library; Spring Boot wraps it with auto-configuration, embedded Tomcat, and sensible defaults. Raw Spring = manually configure 100+ beans in XML or code. Boot = 10 lines of code, runs immediately. Boot is 95% of new projects since ~2015. Only use raw Spring if you need non-standard deployment or extremely legacy systems.
▶Spring MVC vs Spring WebFlux — when do I use reactive?
MVC (synchronous, servlet-based, 1 thread per request) is simpler, best for 90% of apps with < 10k concurrent connections. WebFlux (asynchronous, Netty-based, non-blocking) wins for high concurrency (100k+ connections), streaming, or real-time APIs. Cost: WebFlux is harder to debug, test, and reason about. Start with MVC; migrate to WebFlux only if you hit thread pool limits and profiling proves it's the bottleneck.
▶Microservices with Spring Cloud — is it production-ready?
Yes, heavily used at Netflix, Uber, Alibaba. Spring Cloud provides: Service Registry (Eureka), Config Server, Circuit Breaker (Hystrix/Resilience4j), API Gateway, Distributed Tracing (Sleuth), Load Balancing. Trade-off: distributed complexity. Single monolith is easier to operate; use microservices only after you outgrow a 50-100 person team or > 10M req/day. Spring Cloud abstracts much operational pain.
▶Dependency Injection in Spring — how does it actually work?
@Autowired beans are managed by the ApplicationContext (Spring IoC container). Constructor injection (preferred) ensures immutability and testability. Field injection (@Autowired on property) is tempting but couples your tests to Spring, making them harder to mock. Setter injection is middle ground. Rule: use constructor injection always; field injection only in legacy code.
▶Spring Data JPA vs raw Hibernate — do I need the abstraction?
Spring Data JPA wraps Hibernate (or any JPA provider) with repository interfaces and query DSL. Benefits: type-safe queries, less boilerplate, automatic CRUD. Downside: obscures what SQL runs; lazy-loading pitfalls (N+1 queries). Best practice: use Spring Data for 80% of queries; drop to native SQL (@Query) for complex aggregations or performance-critical paths. Always profile queries with statistics=true.
▶Native compilation with Spring Boot and GraalVM — is it worth it?
GraalVM native-image compiles Java bytecode to machine code: 10x faster startup, 4x less memory, cold-start for serverless. Downside: reflection, proxies, and dynamic class loading don't work by default (JPA/Spring Cloud need manual configuration). Use for: Lambda, containers with fast boot SLA, high-scale Kubernetes clusters. Skip for: development, internal tools, monoliths with 30s startup accepted.
▶Spring Boot 3 / Spring 6 — what changed?
Major breaking changes in 2023: Java 17+ required (no more Java 8), Spring Web MVC uses jakarta.* (not javax.*), removed deprecated APIs (WebMvcConfigurerAdapter, etc.). Gradle/Maven plugins updated. For new projects: mandatory. For legacy Spring Boot 2 apps: no rush, security updates available until 2026, but plan migration. Most code ports with search-replace (javax → jakarta).