Hibernate注解配置错误之解决方案
1.异常一:Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.demo .domain.User"/>
解决方案:检查Sping配置
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 指定要加载的Hibernate配置文件是类路径下的hibernate.cfg.xml文件 -->
<property name="configLocation"
value="classpath:hibernate.cfg.xml" />
</bean>
改成
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 指定要加载的Hibernate配置文件是类路径下的hibernate.cfg.xml文件 -->
<property name="configLocation"
value="classpath:hibernate.cfg.xml" />
</bean>