并使用新的spring java配置:
@Bean public HibernateExceptionTranslator hibernateExceptionTranslator(){ return new HibernateExceptionTranslator(); }解决方法
在使用Hibernate 4.0.0 CR7迁移到Spring Framework 3.1.0 RC1之后,出现以下异常
2011-12-08 / 11:48:38.425 / EST[Thread-17]错误上下文初始化失败org.springframework.beans.factory.BeanCreationException:创建名称为org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0的bean时出错在ServletContext资源[/WEB-INF/applicationContext-hibernate.xml]中定义:Bean初始化失败;嵌套异常是java.lang.IllegalStateException:在bean工厂中找不到持久性异常转换器。无法执行异常转换。在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:530)在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:459)在org.springframework.beans.factory。支持。无法执行异常转换。org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:142)上org.springframework.dao.support.PersistenceExceptionTranslationInterceptor。(PersistenceExceptionTranslationInterceptor.java:79)org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor。.java:70),位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1465),位于org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103)。beans.factory.support。