Strategy for many DAOs in Spring Java
问题 We have many DAOs in an existing project (currently with no interfaces, but that can change). Rather than wiring a Spring-managed bean for each DAO class and injecting them into the service layer, we have a DAO "factory" of sorts that looks like this: public class DAOFactory { private static DAOFactory daoFac; static{ daoFac = new DAOFactory(); } private DAOFactory(){} public static DAOFactory getInstance(){ return daoFac; } public MyDAO1 getMyDAO1(){ return new MyDAO1(); } public MyDAO2