1、在使用Spring+Mybatis整合时遇到了一个问题,在bean.xml配置文件引用外部jdbc.properties的时候报错,如下所示:
1 java.lang.ClassNotFoundException: ${jdbc.driver}
2 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
3 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
4 at java.lang.Class.forName0(Native Method)
5 at java.lang.Class.forName(Class.java:264)
6 at com.mchange.v2.c3p0.DriverManagerDataSource.ensureDriverLoaded(DriverManagerDataSource.java:100)
7 at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:132)
8 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
9 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
10 at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
11 at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
12 at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
13 at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
14 at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
15 [laboratory] 2021-02-24 09:40:42.339 < WARN> [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] BasicResourcePool.run(1841) | com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@398ac721 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
16 java.sql.SQLException: No suitable driver
17 at java.sql.DriverManager.getDriver(DriverManager.java:315)
18 at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223)
19 at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134)
20 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182)
21 at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171)
22 at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137)
23 at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014)
24 at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32)
25 at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810)
26 at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
27 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
28 ### Error querying database. Cause: java.lang.RuntimeException: java.sql.SQLException: Connections could not be acquired from the underlying database!
29 ### Cause: java.lang.RuntimeException: java.sql.SQLException: Connections