spring中注入bean的方法: 1.通过xml文件来注入bean。 2.通过java注解来注入 默认的bean生命周期是单例的。每次都会返回相同的类的实例。 转载于:https://www.cnblogs.com/leiwei/p/3574606.html