我越來越遷移到Spring框架3.1.0 RC1與Hibernate 4.0.0 CR7沒有在bean factory中發現的持久化異常轉換程序。無法執行異常轉換
2011-12-08/11後,以下情況除外:48:38.425/EST [主題-17 ]錯誤上下文初始化失敗 org.springframework.beans.factory.BeanCreationException:在ServletContext資源[/WEB-INF/applicationContext-hibernate.xml]中定義名稱爲'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' :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.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support .AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.context.support.AbstractApplica tionContext.registerBeanPostProcessors(AbstractApplicationContext.java:728) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449) 在org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381) 在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) 在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) 在org.apache.catalina.core。 StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext $ 1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext $ 1.call(StandardContext.java: 5221) at java.util.concurrent.FutureTask $ Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java .util.concurrent.ThreadPoolExecutor $ Worker.run(未知源) at java.lang.Thread.run(未知源) 引起:java.lang.IllegalStateException:在bean工廠中找不到持久性異常轉換程序。無法執行異常翻譯。 在org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:142) 在org.springframework.dao.support.PersistenceExceptionTranslationInterceptor。(PersistenceExceptionTranslationInterceptor.java:79) 在org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor (PersistenceExceptionTranslationAdvisor.java:70) 在org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:103) 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1465) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor y.initializeBean(AbstractAutowireCapableBeanFactory.java:1433) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) ...18更多
確實PersistenceExceptionTranslationPostProcessor要求來定義任何其他豆類。我從來沒有用過它,但我猜這是什麼導致你的錯誤。 – JustinKSU
看起來,您需要在[PersistenceExceptionTranslator](http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/dao/support/PersistenceExceptionTranslator.html)中定義其中一個派生項bean配置。 – srkavin