2012-09-02 56 views
1

在哪裏,我想,以指示類的依賴,當我得到錯誤信息:類「com.mchange.v2.c3p0.ComboPooledDataSource」未找到

  • 類「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> 

回答

1

首先,我建議使用相同版本的命名空間。在你的情況下,採取2.5或3.0。 甚至current version 但是不要在同一個項目中使用不同的版本。

關於你的第一個問題:

類 'com.mchange.v2.c3p0.ComboPooledDataSource' 未找到

已包含在類路徑 'c3p0-0.9.1.2.jar' ?

在第二種情況下,根據您決定使用的Spring版本,您應該包含類路徑'spring-jdbc-x.x.jar'。