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 ();