报错 com.alibaba.druid.pool.DruidDataSource error严重:java.sql.SQLException: ${jdbc.driver}
作者:mmseoamin日期:2023-12-25
E:\Java\jdk1.8.0_172\bin\java.exe "-javaagent:D:\IntelliJ IDEA 2022.3.3\lib\idea_rt.jar=53003:D:\IntelliJ IDEA 2022.3.3\bin" -Dfile.encoding=UTF-8 -classpath E:\Java\jdk1.8.0_172\jre\lib\charsets.jar;E:\Java\jdk1.8.0_172\jre\lib\deploy.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\access-bridge-64.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\cldrdata.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\dnsns.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\jaccess.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\jfxrt.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\localedata.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\nashorn.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\sunec.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\sunjce_provider.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\sunmscapi.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\sunpkcs11.jar;E:\Java\jdk1.8.0_172\jre\lib\ext\zipfs.jar;E:\Java\jdk1.8.0_172\jre\lib\javaws.jar;E:\Java\jdk1.8.0_172\jre\lib\jce.jar;E:\Java\jdk1.8.0_172\jre\lib\jfr.jar;E:\Java\jdk1.8.0_172\jre\lib\jfxswt.jar;E:\Java\jdk1.8.0_172\jre\lib\jsse.jar;E:\Java\jdk1.8.0_172\jre\lib\management-agent.jar;E:\Java\jdk1.8.0_172\jre\lib\plugin.jar;E:\Java\jdk1.8.0_172\jre\lib\resources.jar;E:\Java\jdk1.8.0_172\jre\lib\rt.jar;E:\aCode\idea代码\Spring_test\target\classes;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-context.2.4.RELEASE\spring-context-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-aop.2.4.RELEASE\spring-aop-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\aopalliance\aopalliance.0\aopalliance-1.0.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-beans.2.4.RELEASE\spring-beans-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-core.2.4.RELEASE\spring-core-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\commons-logging\commons-logging.2\commons-logging-1.2.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-expression.2.4.RELEASE\spring-expression-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\com\alibaba\druid.0.9\druid-1.0.9.jar;E:\Java\jdk1.8.0_172\lib\jconsole.jar;E:\Java\jdk1.8.0_172\lib\tools.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\mysql\mysql-connector-java.1.41\mysql-connector-java-5.1.41.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\mybatis\mybatis.2.8\mybatis-3.2.8.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\mybatis\mybatis-spring.2.2\mybatis-spring-1.2.2.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-jdbc.2.6.RELEASE\spring-jdbc-4.2.6.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-tx.2.6.RELEASE\spring-tx-4.2.6.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\javax\servlet\javax.servlet-api.1.0\javax.servlet-api-3.1.0.jar com.peng.test.ApplictionContext
六月 03, 2023 12:54:11 下午 org.springframework.context.annotation.AnnotationConfigApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7daf6ecc: startup date [Sat Jun 03 12:54:11 CST 2023]; root of context hierarchy
com.peng.service.impl.UserServiceImpl@765d7657
org.apache.ibatis.binding.MapperProxy@74235045
六月 03, 2023 12:54:12 下午 com.alibaba.druid.pool.DruidDataSource error
严重: dataSource init error
java.sql.SQLException: ${jdbc.driver}
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:520)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:583)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
	at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:81)
	at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
	at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:72)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
	at com.sun.proxy.$Proxy18.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy19.SelectAll(Unknown Source)
	at com.peng.service.impl.UserServiceImpl.show(UserServiceImpl.java:57)
	at com.peng.test.ApplictionContext.main(ApplictionContext.java:18)
Caused by: java.lang.ClassNotFoundException: ${jdbc.driver}
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:518)
	... 30 more
六月 03, 2023 12:54:12 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited
Exception in thread "main" org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}
### The error may exist in com/peng/mapper/UserMapper.xml
### The error may involve com.peng.mapper.UserMapper.SelectAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
	at com.sun.proxy.$Proxy18.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
	at com.sun.proxy.$Proxy19.SelectAll(Unknown Source)
	at com.peng.service.impl.UserServiceImpl.show(UserServiceImpl.java:57)
	at com.peng.test.ApplictionContext.main(ApplictionContext.java:18)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}
### The error may exist in com/peng/mapper/UserMapper.xml
### The error may involve com.peng.mapper.UserMapper.SelectAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
	... 8 more
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ${jdbc.driver}
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
	at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:81)
	at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
	at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:72)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
	... 14 more
Caused by: java.sql.SQLException: ${jdbc.driver}
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:520)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:583)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:915)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:911)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:98)
	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
	... 24 more
Caused by: java.lang.ClassNotFoundException: ${jdbc.driver}
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:518)
	... 30 more
进程已结束,退出代码1

解决办法

pom.xml中提高  Spring核心依赖版本

修改前:

        
        
            org.springframework
            spring-context
            4.2.4.RELEASE
        

修改后

        
        
            org.springframework
            spring-context
            5.3.7
        

成功解决

报错 com.alibaba.druid.pool.DruidDataSource error严重:java.sql.SQLException: ${jdbc.driver},第1张

可能原因

修改之前是这样的 mysql驱动版本高于spring核心

        
        
            org.springframework
            spring-context
            4.2.4.RELEASE
        
        
        
            mysql
            mysql-connector-java
            5.1.49
        

 修改后 spring核心版本高于mysql驱动

        
        
            org.springframework
            spring-context
            5.3.7
        
        
        
            mysql
            mysql-connector-java
            5.1.49