To use prototype scope with annotations, we only need to mention prototype in the @Scope annotation instead of singleton. So, our EmailService.java class will be the same, except we change the annotation value, and it will look as follows:
@Service
@Scope("prototype")
public class EmailService {
...
}
As like the XML example output, this will also create a new instance each time it is called. In a similar way, we can use other scopes, such as request, session, application, and global session, using XML metadata or annotations.