Skip to content

Instantly share code, notes, and snippets.

@j-tim
Created September 29, 2019 18:56
Show Gist options
  • Select an option

  • Save j-tim/228537e6ae3e72a60ccc538030cd181b to your computer and use it in GitHub Desktop.

Select an option

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
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