Tagged articles
PostConstruct
14 articles · Page 1 of 1

Java OneDec 13, 2025 · Backend Development
This guide explains the Spring bean lifecycle, focusing on the key initialization and destruction hook methods using @PostConstruct and @PreDestroy annotations, with code examples, usage tips, and important considerations for prototype-scoped beans.
Bean LifecycleJavaPostConstruct
0 likes · 4 min read

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

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

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

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

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

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.
ApplicationRunnerCommandLineRunnerJava
0 likes · 5 min read

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.
ApplicationContextJavaPostConstruct
0 likes · 6 min read

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.
ApplicationContextJavaPostConstruct
0 likes · 6 min read

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 RetrievalJava
0 likes · 5 min read

This article explains six practical techniques for executing custom logic during Spring Boot startup, covering ApplicationListener events, CommandLineRunner, ApplicationRunner, @PostConstruct, @Bean initMethod, and InitializingBean, with code examples and brief analysis of each approach.
ApplicationRunnerCommandLineRunnerPostConstruct
0 likes · 10 min read

This article explains the JSR‑250 @PostConstruct annotation, its specifications, how Spring implements its lifecycle handling, execution timing, practical code examples, the deprecation in Java 9+, and alternative approaches such as InitializingBean and DisposableBean.
DependencyInjectionJavaLifecycle
0 likes · 10 min read

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

This article explains how Spring's bean lifecycle can be customized using BeanPostProcessor, @PostConstruct, InitializingBean, and initMethod, providing code examples, execution logs, and best‑practice scenarios for extending bean creation and initialization in backend Java applications.
Bean LifecycleBeanPostProcessorInitializingBean
0 likes · 8 min read
