We can define a class to be Singleton or Prototype. If the class was defined as Prototype, then everytime when we use new keyword, it will create a new instance. // Singleton @Service("customerService") @Scope(ConfigurableBeanFactory.SCOPE_SINGL…
在Spring里面,当一个singleton bean依赖一个prototype bean,那么,因为singleton bean是单例的,因此prototype bean在singleton bean里面也会变成单例,例如: public class Main{ private Man man; //这里注入一个prototype的Man实例 public void setMan(Man man) { this.man= man; } public Man getM…