Canal Adapter com.alibaba.druid.pool.DruidDataSource cannot be cast to com.alibaba.druid.pool.DruidDataSource

原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/15075936.html

 

使用 Canal 同步 MySQL 的数据到 ES,遇到一个超级大坑

java.lang.ClassCastException: com.alibaba.druid.pool.DruidDataSource cannot be cast to com.alibaba.druid.pool.DruidDataSource

 

原因是 druid 包冲突导致的,解决办法如下

下载源码包

wget https://github.com/alibaba/canal/archive/refs/tags/canal-1.1.5.tar.gz

 

解压后,使用IDEA打开,定位到 client-adapter.escore 模块的 pom.xml 的 druid 更新为

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <scope>provided</scope>
</dependency>

 

更新后,在项目根目录下执行

mvn clean package

 

然后到 canal-canal-1.1.5/client-adapter/es7x/target 下 将打包好的 client-adapter.es7x-1.1.5-jar-with-dependencies.jar 替换掉 canal-adapter/plugin 下原来的

 

重启 Canal Adapter,发现日志不再报错,问题成功解决。

 

Reference

https://github.com/alibaba/canal/issues/3144

https://github.com/alibaba/canal/releases

 


 

欢迎点赞关注和收藏

 

posted @ 2021-07-29 16:53  李白与酒  阅读(2621)  评论(0编辑  收藏  举报