Spring Bean Life-cycle Callback
@Configuration static class LifeCycleConfig { @Bean(initMethod = "init", destroyMethod = "close") public NetworkClient networkClient() { NetworkClient networkClient = new NetworkClient(); networkClient.setUrl("http://hello-spring.dev"); return networkClient; } }import jakarta.annotation.PostConstruct; import jakarta.annotation.PreDestroy;
@Bean(initMethod = "init", destroyMethod = "close")
Last updated