Spring AOT (Ahead-of-Time) phân tích cấu hình ứng dụng lúc build time thay vì runtime.
- Thay vì dùng reflection để resolve beans lúc chạy, AOT processor pre-calculate: bean definitions, proxy classes, và metadata — sinh ra code Java thuần (không cần reflection).
- Kết quả: startup nhanh hơn, memory thấp hơn, compatible với GraalVM Native Image.
- Khác biệt: DI truyền thống dùng
ApplicationContextload lúc runtime qua reflection/classpath scanning; AOT làm điều đó lúc build. - Ràng buộc: không thể đăng ký bean động lúc runtime (dynamic
BeanDefinitionRegistryPostProcessorbị hạn chế). - Kích hoạt: tự động khi dùng
spring-boot-maven-pluginvới goalprocess-aothoặc build native image.