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

这篇具有很好参考价值的文章主要介绍了报错 com.alibaba.druid.pool.DruidDataSource error严重:java.sql.SQLException: ${jdbc.driver}。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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\4.2.4.RELEASE\spring-context-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-aop\4.2.4.RELEASE\spring-aop-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-beans\4.2.4.RELEASE\spring-beans-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-core\4.2.4.RELEASE\spring-core-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-expression\4.2.4.RELEASE\spring-expression-4.2.4.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\com\alibaba\druid\1.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\5.1.41\mysql-connector-java-5.1.41.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\mybatis\mybatis\3.2.8\mybatis-3.2.8.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\mybatis\mybatis-spring\1.2.2\mybatis-spring-1.2.2.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-jdbc\4.2.6.RELEASE\spring-jdbc-4.2.6.RELEASE.jar;D:\software\maven\apache-maven-3.9.2\mvn_resp\org\springframework\spring-tx\4.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\3.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核心依赖版本

修改前:

        <!--Spring核心-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.4.RELEASE</version>
        </dependency>

修改后

        <!--Spring核心-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.7</version>
        </dependency>

成功解决

com.alibaba.druid.pool.druiddatasource cannot be cast to java.sql.driver,java,spring,intellij-idea

可能原因

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

        <!--Spring核心-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.4.RELEASE</version>
        </dependency>

        <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>

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

        <!--Spring核心-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.7</version>
        </dependency>

        <!--mybatis驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.49</version>
        </dependency>

 文章来源地址https://www.toymoban.com/news/detail-770215.html

到了这里,关于报错 com.alibaba.druid.pool.DruidDataSource error严重:java.sql.SQLException: ${jdbc.driver}的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • MAC 打开Intellij 报错:com.intellij.diagnostic.PluginException: Fatal error initializing ‘com.alibaba...

    在网上找了很多办法,都没法解决问题。最后自己研究了一下,解决了。主要是plugin缺少包. 到idea官方插件库下载响应插件,解压后复制到下面路径中plugins文件夹中。 https://plugins.jetbrains.com/plugin/10046-alibaba-java-coding-guidelines/versions

    2024年02月11日
    浏览(43)
  • Error:(3, 28) java: 程序包com.alibaba.fastjson不存在

    情景:查看WebRoot——WEB-INF——lib已存在json包 json-lib-2.4-jdk15.jar commons-beanutils-1.8.0.jar commons-logging-1.1.1.jar commons-collections-3.2.1.jar commons-lang-2.5.jar ezmorph-1.0.6.jar 报错 : Error:(3, 28) java: 程序包com.alibaba.fastjson不存在 解决:添加json包 1、点击File——Project Structure  2 、选择Module——

    2024年02月03日
    浏览(46)
  • 【Java】“com.alibaba.fastjson.JSONObject cannot be cast to“报错问题

    报错如下: 通过 debug 断点可以看到,这里拿到虽然是 List,但是里面的对象还是一个 JSONObject,并不是需要的 DTO 类,所有导致了后面的报错。 查到问题根源,只要把这里的对象转化为 DTO 类就行了,就可以避免报错。 增加代码: 我的json \\\"[{},{}]\\\" 已经存为字符串所以改写这样

    2024年02月13日
    浏览(55)
  • Convert data com.alibaba.excel.metadata.data.ReadCellData@3238d9a8 to class java.lang.Integer error

    今天在做Excel导入数据的时候发现的这个异常Convert data com.alibaba.excel.metadata.data.ReadCellData@3238d9a8 to class java.lang.Integer error;看上去就是类型转换异常. 这里看一下报错之前的代码:  这一步是调用工具类把实体类zhCopyrightFilmLibraryReap复制给zhCopyrightFilmLibrary; 看一下解决后的代码:

    2024年02月11日
    浏览(57)
  • 解决com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.83

    在日志中,Fastjson似乎试图将 StandardMultipartHttpServletRequest 序列化为JSON这可能是因为 HttpServletRequest 被错误地传递给了Fastjson,而不是 MultipartFile 查看代码           看到问题可能出现在尝试将MultipartFile转换为JSON时具体来说,Fastjson库在尝试序列化HttpServletRequest对象时可能

    2024年02月03日
    浏览(58)
  • Spark写入Hive报错Mkdir failed on :com.alibaba.jfs.JindoRequestPath

            程序很简单,就是数仓ODS层计算逻辑,直接从阿里云OSS读取数据,补充上一些必要的列,最后数据落盘到hive表。 3.1 分析报错内容         根据下面两段报错提示可以得出:Spark Driver在写入Hive时,试图在oss://sync-to-bi.[马赛克].aliyuncs.com/tmp/hive这个路径下创建目

    2024年02月11日
    浏览(42)
  • (已解决)redis.get报错com.alibaba.fastjson.JSONException: autoType is not support

    redis存取值问题,存自定义实体对象; 第一次取的时候报错: com.alibaba.fastjson.JSONException: autoType is not support 。 GenericFastJsonRedisSerializer序列化和反序列化redis的value值,需要bean对象含有无参构造方法。 解决:         检查自定义实体对象是否有无参构造方法 ;添加有参构造后

    2024年02月12日
    浏览(48)
  • Alibaba Druid整合

    Druid官网:https://github.com/alibaba/druid Druid官网文档(中文):https://github.com/alibaba/druid/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 引入 Druid 的依赖: 配置数据源、监控页面的 Servlet、Filter 整合完成,现在直接使用 Spring IoC 容器中的 DataSource 对象或 JdbcTemplate 即可。 引入 Druid 官方提供的

    2024年02月08日
    浏览(41)
  • nacos下线服务报错:caused: errCode: 500, errMsg: do metadata operation failed ;caused: com.alibaba.nacos.co

    使用nacos下线一个节点的服务时,弹窗报错: 1、先停掉nacos 2、到nacos安装目录下,找到data-protocal 3、把protocal整个文件夹删了,然后重启nacos就行了

    2024年02月12日
    浏览(45)
  • java.util.LinkedHashMap cannot be cast to com.alibaba.fastjson.JSONObject

    接收postman 发送的请求,请求参数是 JSONObject 格式,需要获取其中的info对象 public void xxxxxx(@RequestBody JSONObject map) { // 先将info转成json格式的字符串,再转为JSON对象 JSONObject info = JSON.parseObject(JSON.toJSONString(map.get(“info”))); }

    2024年02月14日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包