Created
September 29, 2019 18:50
-
-
Save j-tim/47513968efb8db809497fcce2821f4b7 to your computer and use it in GitHub Desktop.
Service class annotation with @lazy (Since Spring Framework 5.2 and Spring Boot 2.2) to enable 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 | |
@Slf4j | |
public class LazyInitializedService { | |
@PostConstruct | |
public void afterBeanInitialized() { | |
log.info("Bean 'LazyInitializedService' initialized..."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment