Created
September 29, 2019 18:56
-
-
Save j-tim/228537e6ae3e72a60ccc538030cd181b to your computer and use it in GitHub Desktop.
Service class annotated with @lazy(value = false) (Since Spring Framework 5.2 and Spring Boot 2.2) to disable lazy bean initialization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package nl.jtim.spring.boot.lazy; | |
| import lombok.extern.slf4j.Slf4j; | |
| import org.springframework.context.annotation.Lazy; | |
| import org.springframework.stereotype.Service; | |
| import javax.annotation.PostConstruct; | |
| @Service | |
| @Lazy(value = false) | |
| @Slf4j | |
| public class NonLazyInitializedService { | |
| @PostConstruct | |
| public void afterBeanInitialized() { | |
| log.info("Bean 'NonLazyInitializedService' initialized..."); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment