博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring使用tomcat连接池连接mysql报Driver class not found
阅读量:4080 次
发布时间:2019-05-25

本文共 921 字,大约阅读时间需要 3 分钟。

BUG情景:项目使用spring的jdbc连连接数据库,同时引用了tomcat连接池。项目使用maven管理jar包,明明已经加入了mysql的依赖,但是就是报找不到mysql driver class 的异常!╮(╯▽╰)╭

spring-datasource.xml

Bug原因

原因摘录在此:

There is actually a very simple workaround with Spring. Instead of having the Tomcat connection pool create the database connection and fail because of class loader shenanigans, let Spring create it and pass a reference to the connection pool.

...

Then the connection pool will actually use the database connection as a template for creating as many additional connections as it needs.The best part is that you don’t have to mess with tomcat/lib, which you may not even have access to.

转载地址:http://ttsni.baihongyu.com/

你可能感兴趣的文章
QT打开项目提示no valid settings file could be found
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
多线程使用随机函数需要注意的一点
查看>>
getpeername,getsockname
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
Encoding Schemes
查看>>
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Java8 HashMap集合解析
查看>>
自定义 select 下拉框 多选插件
查看>>
Linux常用统计命令之wc
查看>>
fastcgi_param 详解
查看>>
搞定Java面试中的数据结构问题
查看>>
React Native(一):搭建开发环境、出Hello World
查看>>
二叉树的非递归遍历
查看>>
【leetcode】Linked List Cycle (python)
查看>>
【leetcode】Sum Root to leaf Numbers
查看>>
如何成为编程高手
查看>>