当前位置: 代码迷 >> Java Web开发 >> 导入项目报错Could not initialize class com.mchange.v2.c3p0.ComboPooledDataSource解决思路
  详细解决方案

导入项目报错Could not initialize class com.mchange.v2.c3p0.ComboPooledDataSource解决思路

热度:1560   发布时间:2016-04-13 22:30:40.0
导入项目报错Could not initialize class com.mchange.v2.c3p0.ComboPooledDataSource
我又来了。。。
然后导入的还是那个maven项目
然后测试用例的时候报错:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ReadDataSource' defined in class path resource [mysql-datasource-bean-test.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.mchange.v2.c3p0.ComboPooledDataSource
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1039) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:985) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636) ~[spring-beans-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934) ~[spring-context-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:120) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:60) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.delegateLoading(AbstractDelegatingSmartContextLoader.java:102) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:246) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContextInternal(CacheAwareContextLoaderDelegate.java:69) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.springframework.test.context.CacheAwareContextLoaderDelegate.loadContext(CacheAwareContextLoaderDelegate.java:95) ~[spring-test-3.2.12.RELEASE.jar:3.2.12.RELEASE]
... 25 common frames omitted

网上说Could not initialize class com.mchange.v2.c3p0.ComboPooledDataSource这个错误是因为缺少jar包c3p0-0.9.1.2.jar
但是我找了一下build path里面的maven dependencies是有这个jar包的
那么问题来了,应该怎么改错呢~
------解决思路----------------------
去项目的classes的lib目录,看看这个jar存不存在
  相关解决方案