Command Palette

Search for a command to run...

Posts in series "Advanced Spring Boot"

14 posts

[Advanced Spring Boot] Writing Your Own Auto-configuration and Starter

Build and ship a real Spring Boot 4.1.1 starter: the three Gradle projects and the x-spring-boot-starter naming rule, an @AutoConfiguration class with @ConditionalOnMissingBean and @ConditionalOnProperty, registration in AutoConfiguration.imports, ordering with before/after against a Boot auto-configuration, a validated @ConfigurationProperties record with generated spring-configuration-metadata.json, a custom SpringBootCondition with its ConditionOutcome message in the report, five ApplicationContextRunner tests including FilteredClassLoader, publishing to mavenLocal and consuming it, and a FailureAnalyzer for the misconfiguration.

[Advanced Spring Boot] Extending the Spring Container: BeanFactoryPostProcessor, BeanPostProcessor and Aware

The container extension points of Spring Boot 4.1.1, traced through one startup: a numbered run from EnvironmentPostProcessor to the runners, how each callback is registered in Boot 4 and why context.initializer.classes no longer works, BeanFactoryPostProcessor against BeanDefinitionRegistryPostProcessor, a BeanPostProcessor that returns a JDK dynamic proxy, the "not eligible for getting processed by all BeanPostProcessors" trap with the transaction it silently loses, the measured post-processor chain that shows @Order being ignored, the Aware interfaces worth knowing, and what an exception in an ApplicationRunner does to the exit code.

[Advanced Spring Boot] Spring AOP: JDK and CGLIB Proxies, Aspects and Self-Invocation

Spring AOP on Spring Boot 4.1.1: spring-boot-starter-aop is gone from the BOM and spring-boot-starter-aspectj replaces it, JDK dynamic proxy against CGLIB subclass with the real class names, the ClassCastException a JDK proxy causes, the final class that throws AopConfigException, the final method that quietly NPEs because Objenesis skipped the constructor, the pointcut designators that matter, the measured order of all five advice kinds on both paths, @Order between aspects, the self-invocation trap underneath @Transactional and @Async with three fixes compared, the nanosecond cost of a proxied call, and Advised#getAdvisors for debugging.

[Advanced Spring Boot] Spring Events: ApplicationEventPublisher, @EventListener and @TransactionalEventListener

Spring events on Spring Boot 4.1.1: publishing a record through ApplicationEventPublisher and the PayloadApplicationEvent it is wrapped in, proof that @EventListener runs on the caller thread inside the caller transaction, @Order and SpEL condition, a listener that returns another event, why a listener for a generic OrderEvent<Product> never fires without ResolvableTypeProvider, what a throwing listener does synchronously and under @Async, all four @TransactionalEventListener phases with the runs that show which fired, fallbackExecution, the AFTER_COMMIT write that silently loses a row and the REQUIRES_NEW that saves it, @Async listeners against an async applicationEventMulticaster, and where in-process events stop being a reliability mechanism.

[Advanced Spring Boot] JPA Performance: N+1 Detection, Batch Fetching, Projections and Batch Inserts

JPA performance on Spring Boot 4.1.1 and PostgreSQL: counting SQL per request with a StatementInspector and the Hibernate 7 session metrics log, an integration test that fails on N+1, @BatchSize and default_batch_fetch_size with the = any(?) array parameter PostgreSQL receives, FetchMode.SUBSELECT loading 801 rows for a page of 20, the two-query pattern for paging parents with children, closed, open, record, dynamic and native projections and what they leave in the persistence context, and batch inserts where IDENTITY sends 10,000 statements and a pooled SEQUENCE with batch_size, order_inserts and reWriteBatchedInserts sends 600.

[Advanced Spring Boot] Spring Transactions in Depth: Propagation, Isolation Levels and Rollback Rules

Spring transaction propagation, isolation and rollback rules on Spring Boot 4.1.1 with PostgreSQL: all seven propagations with JpaTransactionManager logs and backend pids, the REQUIRES_NEW connection pool deadlock with HikariCP timings, why NESTED fails with JpaTransactionManager and works with JdbcTransactionManager savepoints, non-repeatable reads, lost updates and write skew under each isolation level, SQLSTATE 40001 as CannotAcquireLockException, a correct retry around the transaction, readOnly at the JDBC, PostgreSQL and Hibernate layers, validateExistingTransaction, rollbackOn ALL_EXCEPTIONS and what really enforces @Transactional(timeout).