java 找不到类“com.mchange.v2.c3p0.ComboPooledDataSource”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12235969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found
提问by John Smith
Where do I suppose to indicate class dependency when I got error messages:
当我收到错误消息时,我应该在哪里指示类依赖性:
- Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found
- Class 'org.springframework.jdbc.datasource.DataSourceTransactionManager' not found
- 找不到类“com.mchange.v2.c3p0.ComboPooledDataSource”
- 找不到类“org.springframework.jdbc.datasource.DataSourceTransactionManager”
jdbc-context.xml
jdbc-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="/WEB-INF/spring.properties" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close"
p:driverClass="${jdbc.driverClassName}"
p:jdbcUrl="${jdbc.url}"
p:user="${jdbc.username}"
p:password="${jdbc.password}"
p:acquireIncrement="5"
p:idleConnectionTestPeriod="60"
p:maxPoolSize="100"
p:maxStatements="50"
p:minPoolSize="10" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="dataSource" />
</beans>
回答by Spacemonkey
First of all, I suggest to use the same version of namespaces. In your case take 2.5 or 3.0. Or even current versionBut do not use different versions in same project.
首先,我建议使用相同版本的命名空间。在您的情况下,取 2.5 或 3.0。甚至当前版本但不要在同一个项目中使用不同的版本。
About your first problem:
关于你的第一个问题:
Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found
找不到类“com.mchange.v2.c3p0.ComboPooledDataSource”
Have you included in your classpath 'c3p0-0.9.1.2.jar'?
您是否已将类路径包含在“c3p0-0.9.1.2.jar”中?
In second case you should include to classpath 'spring-jdbc-x.x.jar' depending the version of Spring you decide to use.
在第二种情况下,您应该根据您决定使用的 Spring 版本在类路径中包含“spring-jdbc-xxjar”。
回答by Mihiran Chathuranga
Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found
I resolve this error by copying the c3p0-0.9.1.2.jar
file to the WEB-INF/lib folder.c3p0-0.9.1.2.jar
file was founded by google searching
我通过将c3p0-0.9.1.2.jar
文件复制到WEB-INF/lib folder.c3p0-0.9.1.2.jar
由 google 搜索创建的文件来解决此错误