未找到“com.mchange.v2.c3p0.ComboPooledDataSource”类

时间:2012-09-02 12:31:16

标签: java spring-mvc sts-springsourcetoolsuite

当我收到错误消息时,我想在哪里指出类依赖:

  • Class'com.mchange.v2.c3p0.ComboPooledDataSource'not found
  • Class'org.springframework.jdbc.datasource.DataSourceTransactionManager'not found

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>

2 个答案:

答案 0 :(得分:1)

首先,我建议使用相同版本的命名空间。在你的情况下采取2.5或3.0。 甚至current version 但是不要在同一个项目中使用不同的版本。

关于你的第一个问题:

  

Class&#39; com.mchange.v2.c3p0.ComboPooledDataSource&#39;找不到

您是否已将其纳入课程路径&#39; c3p0-0.9.1.2.jar&#39;?

在第二种情况下,你应该包括classpath&#39; spring-jdbc-x.x.jar&#39;取决于您决定使用的Spring版本。

答案 1 :(得分:0)

Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found

我通过将c3p0-0.9.1.2.jar文件复制到由Google搜索创建的WEB-INF/lib folder.c3p0-0.9.1.2.jar文件中来解决此错误