为啥要使用FactoryBean: 在配置Bean的时候,需要用到IOC容器中的其它Bean,这个时候使用FactoryBean配置最合适. public class Car { private String brand; private double price; public Car() { System.out.println("com.cn.Car's Constructor"); } public Car(String brand, double price) { this.…
1.实现FactoryBean接口 import org.springframework.beans.factory.FactoryBean; public class CarFactoryBean implements FactoryBean<Car> { @Override public Car getObject() throws Exception { // TODO Auto-generated method stub return new Car("Qq",…