通过注解注入方式
1. 在applicationContext.xml定义

在service中定义变量

给出setter方法注解

通过配置注入方式
在需要HibernateTemplate属性的类,加入

就可以直接使用HibernateTemplate了