【问题标题】:Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found找不到类“com.mchange.v2.c3p0.ComboPooledDataSource”
【发布时间】:2012-09-02 12:31:16
【问题描述】:

当我收到错误消息时,我应该在哪里指示类依赖:

  • 找不到类“com.mchange.v2.c3p0.ComboPooledDataSource”
  • 找不到类 'org.springframework.jdbc.datasource.DataSourceTransactionManager'

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>

【问题讨论】:

    标签: java spring-mvc sts-springsourcetoolsuite


    【解决方案1】:

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

    关于你的第一个问题:

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

    您的类路径中是否包含“c3p0-0.9.1.2.jar”?

    在第二种情况下,您应该根据您决定使用的 Spring 版本将“spring-jdbc-x.x.jar”包含到类路径中。

    【讨论】:

      【解决方案2】:
      Class 'com.mchange.v2.c3p0.ComboPooledDataSource' not found
      

      我通过将c3p0-0.9.1.2.jar 文件复制到WEB-INF/lib folder.c3p0-0.9.1.2.jar 文件来解决此错误

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-11
      • 2017-02-16
      • 2019-06-09
      • 1970-01-01
      • 2016-10-28
      • 1970-01-01
      • 2017-04-27
      • 2019-12-08
      相关资源
      最近更新 更多