Using the singleton scope

The singleton scope is a very common scope used in major applications. Here, we will start to use the singleton scope. First, we will create a bean class named EmailService, which consists of a simple getter/setter method and Constructor method with a print statement:

package com.packt.springbean;public class EmailService {    private String emailContent;  private String toAddress;    public EmailService() {    System.out.print(" \n Object of EmailService is Created !!! ");  }    public String getEmailContent() {    return emailContent;  }    public void setEmailContent(String emailContent) {    this.emailContent = emailContent;  }    public String getToAddress() {    return toAddress;  }    public void setToAddress(String toAddress) { this.toAddress ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.