yancheng1014 2017-06-06 02:55 采纳率: 100%
浏览 776
已结题

【跪求大神】使用Spring+mybatis整合,测试数据库连接是报错

http://ask.csdn.net/questions/211665 错误和这位兄弟的报错一样。不知道怎么解决
这是测试类:图片说明

public class TestEmpDAO {

    public static void main(String args[]) {
            String conf = "applicationContext.xml";
            ApplicationContext ac = new ClassPathXmlApplicationContext(conf);
            EmpDAO mapper = ac.getBean("empDAO",EmpDAO.class); 
            List<Emp> list = mapper.findAll();
            for (Iterator it=list.iterator(); it.hasNext();) {
                Emp emp = (Emp)it.next();
                System.out.println(emp.getEname()+"---"+emp.getJob()+"---"+emp.getSal());
            }
    }

}

  • 写回答

2条回答 默认 最新

  • FEN_TA 2017-06-06 03:05
    关注

    EmpDAO mapper = ac.getBean("empDAO",EmpDAO.class);

    empDAO这个BEAN并没有配置吧?

    评论

报告相同问题?