原創轉載請注明出處: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
歡迎點贊關注和收藏