spring整合hibernate时出错(已经导入commons-dbcp2-2.1.1.jar和commons-pool2-2.1.jar)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring整合hibernate时出错(已经导入commons-dbcp2-2.1.1.jar和commons-pool2-2.1.jar)相关的知识,希望对你有一定的参考价值。

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.pool2.impl.GenericObjectPool.setTestOnCreate(Z)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at Test.TestSpringHibernate.main(TestSpringHibernate.java:18)
Caused by: java.lang.NoSuchMethodError: org.apache.commons.pool2.impl.GenericObjectPool.setTestOnCreate(Z)V

applicationContext.xml的配置报错了,无法创建sessionFactory,通常是配置出错,检查一下配置文件吧。 参考技术A jar包冲突了吧本回答被提问者采纳

以上是关于spring整合hibernate时出错(已经导入commons-dbcp2-2.1.1.jar和commons-pool2-2.1.jar)的主要内容,如果未能解决你的问题,请参考以下文章

Spring整合Hibernate与Struts

整合Hibernate

eclipse环境下基于已构建struts2项目整合spring+hibernate

ssh整合

spring4和hibernate4.0.0的整合

Spring:Spring整合Hibernate