xiaowei-ce commented on issue #29381:
URL: 
https://github.com/apache/shardingsphere/issues/29381#issuecomment-4642821653

   Got the same issue with Spring Boot 3.5.14 and sharding-jdbc 5.5.2.
   
   `application.yaml`
   ```yaml
   spring:
     application:
       name: url-convert-backend
     datasource:
       driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
       url: jdbc:shardingsphere:classpath:sharding-jdbc.yaml
   ```
   
   `sharding-jdbc.yaml`
   ```yaml
   dataSources:
     master:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: jdbc:mysql://debian-server:3307/demos
       username: root
       password: abc123
     slave:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: jdbc:mysql://debian-server:3308/demos
       username: root
       password: abc123
   
   rules:
     - !READWRITE_SPLITTING
       dataSources:
         readwrite_ds:
           writeDataSourceName: master
           readDataSourceNames:
             - slave
           loadBalancerName: random
       loadBalancers:
         random:
           type: RANDOM
   ```
   
   Logs:
   ```
   ### Error updating database.  Cause: 
com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to 
initialize pool: Cannot create property=rules for 
JavaBean=org.apache.shardingsphere.driver.yaml.YamlJDBCConfiguration@779ef5cb
    in 'reader', line 1, column 1:
       dataSources:
       ^
   Cannot create property=dataSources for 
JavaBean=org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration@2d33795c
    in 'reader', line 16, column 5:
         - !READWRITE_SPLITTING
           ^
   Unable to find property 'dataSources' on class: 
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration
    in 'reader', line 18, column 7:
             readwrite_ds:
             ^
   
    in 'reader', line 16, column 3:
         - !READWRITE_SPLITTING
         ^
   ```
   
   Here’s how I finally fixed it:
   
   I saw this log line:  
   `Unable to find property 'dataSources' on class: 
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration`
   
   I suspected something was wrong with how the `dataSources` field was being 
parsed, so I looked inside the class 
`org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration`.
  
   
   I didn’t find any `dataSources`... but I did find a field: `private 
Map<String, YamlReadwriteSplittingDataSourceGroupRuleConfiguration> 
dataSourceGroups`.  
   
   Then I tried changing `dataSources` to `dataSourceGroups`, and guess what? 
It worked.  
   I guess  the field name was updated but the documentation wasn't synced...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to