Tagged articles

PostConstruct

14 articles · Page 1 of 1
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Sep 28, 2025 · Backend Development

Master Spring Boot 3 Bean Lifecycle: @PostConstruct & @PreDestroy Alternatives

This article explains the purpose and usage of Spring Boot’s @PostConstruct and @PreDestroy annotations for bean initialization and cleanup, discusses their migration to Jakarta EE in Spring Boot 3+, and presents modern alternatives such as @EventListener with ApplicationReadyEvent, DisposableBean, and destroyMethod configurations, complete with code examples.

Bean LifecycleJavaPostConstruct
0 likes · 8 min read
Master Spring Boot 3 Bean Lifecycle: @PostConstruct & @PreDestroy Alternatives
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Aug 5, 2025 · Backend Development

Master Spring Boot Lifecycle: Init & Destroy Callbacks Explained

This article explains Spring Boot’s bean lifecycle callbacks, covering InitializingBean and DisposableBean interfaces, @PostConstruct and @PreDestroy annotations, initMethod and destroyMethod configurations, as well as alternative approaches like SmartInitializingSingleton, ContextRefreshedEvent, and AutoCloseable, with code examples and execution order details.

DisposableBeanInitializingBeanLifecycle
0 likes · 7 min read
Master Spring Boot Lifecycle: Init & Destroy Callbacks Explained
Xuanwu Backend Tech Stack
Xuanwu Backend Tech Stack
Jul 1, 2025 · Backend Development

Mastering Spring Bean Initialization: @PostConstruct, InitializingBean, and init‑method Explained

This article explains the three Spring bean initialization callbacks—@PostConstruct, InitializingBean, and init‑method—their fixed execution order, underlying processing mechanisms, code examples, and guidance on choosing the most suitable approach for different development scenarios.

Bean InitializationInitializingBeanJava backend
0 likes · 9 min read
Mastering Spring Bean Initialization: @PostConstruct, InitializingBean, and init‑method Explained
Shepherd Advanced Notes
Shepherd Advanced Notes
Oct 31, 2024 · Backend Development

How to Run Custom Code at Spring Boot Startup: 8 Implementation Options

This article explains eight ways to execute custom initialization logic during Spring Boot startup, covering CommandLineRunner, ApplicationRunner, ApplicationListener, @EventListener, @PostConstruct, BeanPostProcessor, InitializingBean, SmartInitializingSingleton, and the main method, with code examples and suitable use‑case guidance.

BeanPostProcessorCommandLineRunnerPostConstruct
0 likes · 10 min read
How to Run Custom Code at Spring Boot Startup: 8 Implementation Options
Architect
Architect
Jun 11, 2024 · Backend Development

Mastering Spring Boot Startup: 11 Critical Questions & Execution Order

This article provides a deep technical analysis of Spring Boot's startup process, explains every relevant extension point, demonstrates how to log and verify execution order with sample code, answers eleven common questions about bean initialization, and offers practical guidance on when to safely open RPC, MQ, and HTTP traffic.

AutowiredBean LifecycleCommandLineRunner
0 likes · 17 min read
Mastering Spring Boot Startup: 11 Critical Questions & Execution Order
Programmer DD
Programmer DD
May 30, 2022 · Backend Development

Master Spring Boot Startup: From static blocks to @PostConstruct and Runner Interfaces

This article explains the various ways to execute code during a Spring Boot application's startup, comparing Java static blocks, constructors, @PostConstruct methods, and Spring's ApplicationRunner and CommandLineRunner interfaces, including ordering with @Order and providing sample code and execution results.

ApplicationRunnerBackend DevelopmentCommandLineRunner
0 likes · 5 min read
Master Spring Boot Startup: From static blocks to @PostConstruct and Runner Interfaces
Programmer DD
Programmer DD
Nov 6, 2021 · Backend Development

Three Ways to Access Spring Beans from Static Methods

This article demonstrates three practical techniques for retrieving Spring-managed beans inside static methods—using @PostConstruct initialization, a static ApplicationContext from the main class, and a manual ApplicationContextAware component—complete with code examples and usage guidelines.

ApplicationContextDependency InjectionJava
0 likes · 6 min read
Three Ways to Access Spring Beans from Static Methods
Java Architect Essentials
Java Architect Essentials
Nov 3, 2021 · Backend Development

Three Ways to Access Spring Beans in Static Methods Using Spring Boot

This article explains three techniques for obtaining Spring beans inside static methods—using @PostConstruct initialization, a static ApplicationContext stored in the main class, and implementing ApplicationContextAware—complete with code examples and detailed guidelines for the @PostConstruct annotation.

ApplicationContextDependency InjectionJava
0 likes · 6 min read
Three Ways to Access Spring Beans in Static Methods Using Spring Boot
Top Architect
Top Architect
Oct 29, 2021 · Backend Development

Three Methods to Obtain Spring Beans in Static Context: @PostConstruct, ApplicationContext, and ApplicationContextAware

This article explains three practical ways to retrieve Spring beans from static methods—using @PostConstruct annotation, a static ApplicationContext defined in the main class, and a manually injected ApplicationContext via ApplicationContextAware—complete with code examples and usage notes.

ApplicationContextBean RetrievalDependency Injection
0 likes · 5 min read
Three Methods to Obtain Spring Beans in Static Context: @PostConstruct, ApplicationContext, and ApplicationContextAware
Top Architect
Top Architect
May 25, 2021 · Backend Development

Spring Boot Resource Initialization: CommandLineRunner, ApplicationRunner, @Order, @PostConstruct, InitializingBean, and ApplicationListener

This article explains several Spring Boot techniques for initializing resources at application startup, including CommandLineRunner, ApplicationRunner, @Order, @PostConstruct, InitializingBean, and ApplicationListener, and provides code examples and usage guidelines for each method.

ApplicationRunnerCommandLineRunnerInitializingBean
0 likes · 8 min read
Spring Boot Resource Initialization: CommandLineRunner, ApplicationRunner, @Order, @PostConstruct, InitializingBean, and ApplicationListener