Spring工厂模式+单例实现解耦
1。BeanFactory 实现解决三层架构new之间的依赖 package bean; import org.springframework.beans.factory.BeanFactory; import javax.xml.ws.soap.Addressing; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; public class FactoryBean { //定义一个Properties private static Properties prop; //定义一个Map,存放所创建的对象 private static Map<String ,Object> beans; //使用静态代码块 static{ try { //1.实例化对象 prop=new Properties(); //2.获取流对象 InputStream in= BeanFactory.class.getClassLoader().getResourceAsStream("bean.properties"); prop