程序中出现了三次错误:
1.第一个是扫描不到hbm.xml文件,原因是hbm.xml文件在com.mmd.action这个包下,所以我在classpath这里写的路径是com.mmd.action/hbm.xml,这样写是不对的,应该是:com/mmd/action/hbm.xml
2.第二个错误是链接数据库的时候一直报找不到org.postgresql的错误,原因是没导入postgresql的jar包
3.在service层中写的set方法
public void setDtDao(DutyDao dtDao) {
this.dutyDao = dtDao;
}
配置文件:
<bean id="dtDao" class="org.crazyit.hrsystem.dao.impl.DutyDaoHibernate"
parent="daoTemplate"/>
spring注入是根据配置文件的id dtDao找对应的set方法也就是找setDutyDao
所以配置文件的id应该和set方法中的参数一致。