nealzyf edited a comment on issue #15086:
URL: 
https://github.com/apache/shardingsphere/issues/15086#issuecomment-1072203609


   Same issue; here is demo
   
   
[shardingSphere-jdbc-sample.zip](https://github.com/apache/shardingsphere/files/8302997/shardingSphere-jdbc-sample.zip)
   
   I also try the below code , but the shardingSphereDataSource via spring aop 
is null in spring boot 2.3.10.
   but this code  is ok in the spring boot 2.5
   
   @Configuration
   public class MyDataSourceConfiguration {
       @Resource
       private DynamicDataSourceProperties properties;
   
       //           shardingSphereDataSource is null
       @Resource(name = "shardingSphereDataSource")
       private ShardingSphereDataSource shardingSphereDataSource;
   
       @Bean
       public DynamicDataSourceProvider dynamicDataSourceProvider() {
           return new AbstractDataSourceProvider() {
   
               @Override
               public Map<String, DataSource> loadDataSources() {
                   Map<String, DataSource> dataSourceMap = new HashMap<>();
                   //           shardingSphereDataSource is null
                   dataSourceMap.put("shardingSphere", 
shardingSphereDataSource);
                   return dataSourceMap;
               }
           };
       }
   
       @Primary
       @Bean
       public DataSource dataSource() {
           DynamicRoutingDataSource dataSource = new DynamicRoutingDataSource();
           dataSource.setPrimary(properties.getPrimary());
           dataSource.setStrict(properties.getStrict());
           dataSource.setStrategy(properties.getStrategy());
           dataSource.setP6spy(properties.getP6spy());
           dataSource.setSeata(properties.getSeata());
           return dataSource;
       }
   }
   


-- 
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