Must specify at least one slave host to connect to for master/slave replication load-balancing functionality

上一篇文章,我们很开心的使用了JDBC的ReplicationDriver来实现读写分离。然后遇到了一个坑,如题所示。
题主系统配置了多个数据源,而其他的数据源并没有配置读写分离,如下:


       
       
       
       



    
    
    
    

但是从官方文档中查阅到:
URL:https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-master-slave-replication-connection.html

Because it accepts the same URL format as the standard MySQL JDBC driver,
ReplicationDriver does not currently work with java.sql.DriverManager-based connection creation
unless it is the only MySQL JDBC driver registered with the DriverManager .

意味着ReplicationDriver 和Driver不能够同时使用。

但是,重点来了,我们再配置数据源的时候只需要将dataSource1的driverClassName设置为com.mysql.jdbc.Driver,驱动根据URL依然可以自动路由。

你可能感兴趣的:(Must specify at least one slave host to connect to for master/slave replication load-balancing functionality)