A small snippet of code to help me present the topic @Service(name="singletonServiceBean") @Scope(value = "singleton") //this is the default value. Explicitly setting it just for readability. public class SingletonServiceBean { private Logger logger = LoggerFactory.getLogger(SingletonServiceBean.class); public SingletonServiceBean() { logger.debug("Constructor called for the service bean"); } @PostConstruct public void initialize() { logger.debug("Initialize the bean in PostConstruct");
Read full article from Spring Singletons and Lifecycle Annotations | Amit's Tech Blog
No comments:
Post a Comment