From what I understand, if scope=”prototype” is given for a bean, a new instance of that class is created on every request. So why would anyone use spring to create a new object instead of simply writing
ClassName newBean = new ClassName();
I have only used spring to create singletons.
Because you might want to inject other beans in your prototype. Or you might want to apply AOP aspects to methods of this bean. Or you might want to make it transactional. Or secure.
If you simply invoke the constructor of the class, it’s not a Spring-managed bean anymore, and everything Spring does with beans is not done to the manually constructed object.