本文共 921 字,大约阅读时间需要 3 分钟。
BUG情景:项目使用spring的jdbc连连接数据库,同时引用了tomcat连接池。项目使用maven管理jar包,明明已经加入了mysql的依赖,但是就是报找不到mysql driver class 的异常!╮(╯▽╰)╭
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/