Overview
- 1Spring Boot 3.3 (May 2024) targets Java 17+ and Spring Framework 6.1.
- 2Virtual Threads (Project Loom): enable with `spring.threads.virtual.enabled=true` — 1M+ concurrent requests.
- 3GraalVM Native Image: compile Spring Boot apps to native executables (5ms startup, 50% less RAM).
- 4CDS auto setup: Class Data Sharing trained and applied automatically for ~40% faster startup.
- 5Service connections: `@ServiceConnection` auto-configures beans for containers in tests.
Key Features in 3.3
Use Cases
- →Microservices and REST APIs in enterprise Java environments
- →Event-driven systems with Spring Kafka or RabbitMQ
- →Batch processing with Spring Batch
- →Cloud-native apps deployed on Kubernetes (Spring Cloud Kubernetes)
What's New in Spring Boot 3.3
- Virtual Threads: set `spring.threads.virtual.enabled=true` in application.properties
- CDS auto-setup: training step runs during build; startup time reduced ~40%
- @ServiceConnection replaces manual @DynamicPropertySource in tests
- RestClient (introduced 3.2) is now the preferred HTTP client over RestTemplate
- spring-boot-docker-compose module auto-starts Docker Compose on app start
- @ConditionalOnThreading(VIRTUAL/PLATFORM) for thread-model-aware bean conditions
- SSL bundle reloading — certificates can be refreshed without restart
Core Annotations & Patterns
- @SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan
- @RestController + @RequestMapping: define REST endpoints; @GetMapping, @PostMapping shorthands
- @Service, @Repository, @Component: stereotypes that trigger Spring bean detection
- @Autowired (or constructor injection preferred): injects dependencies from application context
- @Value("${property}"): inject values from application.properties/yaml
- @ConfigurationProperties(prefix="app"): bind a group of properties to a typed POJO
- @Transactional: declarative transaction management around methods or classes
Spring Data JPA & Persistence
- JpaRepository<Entity, ID> provides CRUD, pagination, and sorting out of the box
- Derived query methods: `findByEmailAndStatus(email, status)` generates JPQL automatically
- @Query("JPQL or native SQL"): explicit queries with named parameters
- Hibernate 6.4 (Spring Boot 3.3): improved type-safe criteria queries, batch inserts
- Spring Data JDBC: lighter alternative to JPA for simple CRUD without Hibernate overhead
- Flyway/Liquibase: schema migration management integrated via auto-configuration
Spring Security 6.x
- Lambda DSL (HttpSecurity::authorizeHttpRequests) replaces deprecated chained methods
- SecurityFilterChain @Bean replaces WebSecurityConfigurerAdapter inheritance
- OAuth2 Resource Server: `spring-security-oauth2-resource-server` for JWT validation
- Method Security: @PreAuthorize("hasRole('ADMIN')") and @PostAuthorize expressions
- CSRF protection: CookieCsrfTokenRepository for SPAs; disable for stateless REST APIs
- Password encoding: BCryptPasswordEncoder (strength 12) is the production standard
Frequently Asked Questions
How do Virtual Threads improve Spring Boot performance?
Virtual Threads (Project Loom, Java 21+) are lightweight threads managed by the JVM rather than the OS. One JVM can run millions of virtual threads with minimal memory overhead. In Spring Boot 3.3, enabling virtual threads (`spring.threads.virtual.enabled=true`) turns every Tomcat request into a virtual thread, eliminating I/O blocking without reactive programming complexity.
What is GraalVM native image in Spring Boot?
GraalVM native image compiles a Spring Boot application ahead-of-time into a native binary. The result starts in ~5ms (vs 2-5 seconds for JVM), uses 50% less memory, and contains no JVM dependency. Use `mvn spring-boot:build-image` with GraalVM. Spring AOT processing resolves reflective and proxy configurations at build time.
Spring MVC vs Spring WebFlux — when to use which?
Use Spring MVC with Virtual Threads for most applications — it is simpler, has better tooling, and Virtual Threads provide reactive-level concurrency without the learning curve. Use Spring WebFlux only when you need backpressure semantics, streaming responses, or are building on reactive data stores like R2DBC or MongoDB Reactive.