ssh框架,spring3配置c3p0数据源找不到jdbc的其中一个原因

时间:2021-10-20 07:55:10

启动Tomcat时出错


WARN  com.mchange.v2.c3p0.DriverManagerDataSource [DriverManagerDataSource] Could not load driverClass "com.mysql.jdbc.Driver"
java.lang.ClassNotFoundException: "com.mysql.jdbc.Driver"
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:101)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:133)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)


数据源的配置

  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

                  <property name="driverClass">
                        <value>"com.mysql.jdbc.Driver"</value> 
                </property>  
                <property name="jdbcUrl">
                        <value>jdbc:mysql://localhost:3306/myssh?useUnicode=true&amp;                    characterEncoding=UTF-8</value>  
                </property>
                <property name="user" value="root"></property>
                <property name="password" value="123456"></property>
</bean>


!注意红色部分,把 引号去掉就运行OK了,要不就写成 <property name="driverClass" value="com.mysql.jdbc.Driver" />,问题就解决了...............