请教这个如何解决,我对反射不熟//实现类
import dao.system.CompanyDao;
import dao.system.CountryDao;
public class SystemDaoFactory {
private final String daoImpl = "ConutryDaoImpl";
//getcoutnrydao
public CountryDao getConutryDao()throws Exception{
CountryDao ctd = null;
ctd = (CountryDao)Class.forName(daoImpl).newInstance();
return ctd;
}//测试
import util.db.SystemDaoFactory;
import dao.system.CountryDao;
import entity.system.Countrys;public class TestSystemDao { /**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Countrys countrys = null;
CountryDao cDao = null;
cDao = new SystemDaoFactory().getConutryDao();
countrys = cDao.selectId(2);
System.out.println(countrys.toString()); }}我这个方法抛出
java.lang.ClassNotFoundException: ConutryDaoImpl
import dao.system.CompanyDao;
import dao.system.CountryDao;
public class SystemDaoFactory {
private final String daoImpl = "ConutryDaoImpl";
//getcoutnrydao
public CountryDao getConutryDao()throws Exception{
CountryDao ctd = null;
ctd = (CountryDao)Class.forName(daoImpl).newInstance();
return ctd;
}//测试
import util.db.SystemDaoFactory;
import dao.system.CountryDao;
import entity.system.Countrys;public class TestSystemDao { /**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Countrys countrys = null;
CountryDao cDao = null;
cDao = new SystemDaoFactory().getConutryDao();
countrys = cDao.selectId(2);
System.out.println(countrys.toString()); }}我这个方法抛出
java.lang.ClassNotFoundException: ConutryDaoImpl
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货