I wanted to know if we only do ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
in our main method and don't do Coach coach1=context.getBean("myCoach5",Coach.class);
where suppose "Coach" is my class and "myCoach5" is id of bean having prototype scope defined in applicationContext.xml. Then in case of prototype-scope will constructor led dependency be injected? Will its constructor's content run?
I observe it does not work in prototype scope but works in case of singleton scope with everything else remaining the same.
Asked
Active
Viewed 15 times
0

krr
- 55
- 7
-
Hope this answer your question [Visit here](https://stackoverflow.com/questions/25000406/how-many-instances-created-for-singleton-bean-referring-to-a-session-bean-protot#:~:text=You%20cannot%20dependency%2Dinject%20a,resolving%20and%20injecting%20its%20dependencies.) – Puneet Kundliya Jul 12 '22 at 16:07
-
when is prototype scoped bean instantiated in spring? like if we don't fetch that bean using getBean then also will it be created? I notice for singleton scoped bean instance of bean get created even though I don't use getBean. – krr Jul 13 '22 at 03:53