getHibernateTemplate() 一直报NullPointerException 错误

原来是调用方法有误正确调用方法:

 ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); 
        com.springmvc.hibernate.NewsDAO newsdao=(NewsDAO) ctx.getBean("NewsDAO");
        com.springmvc.hibernate.News news=new com.springmvc.hibernate.News();        
        news.setId(1);
        news.setTitle("1111111");
        news.setContents("333333333");
        news.setUpdatetime( new Timestamp(System.currentTimeMillis()));
        newsdao.save(news);


错误调用方法:

 com.springmvc.hibernate.NewsDAO newsdao =new com.springmvc.hibernate.NewsDAO ();

posted on   lvlv岁月流逝  阅读(409)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示