如果不用注入,代码是不是应该这样写,用注入就是省去了new的过程,是这样吗?
// 不用设值注入 public void testSetter(){ InjectionDAO injectionDAOPara = new InjectionDAOImpl(); InjectionService service = new InjectionServiceImpl(); service.setInjectionDAO(injectionDAOPara); service.save("这是要保存的数据"); } // 不用构造注入 public void testCons(){ InjectionDAO injectionDAOPara = new InjectionDAOImpl(); InjectionService service = new InjectionServiceImpl(injectionDAOPara); service.save("这是要保存的数据"); }