shangdjing opened a new issue, #32342:
URL: https://github.com/apache/shardingsphere/issues/32342

   ### Which version of ShardingSphere did you use?
   <dependency>
       <groupId>org.apache.shardingsphere</groupId>
       <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
       <version>5.2.1</version>
   </dependency>
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC 
   ### My application.yml
   spring:
     shardingsphere:
       datasource:
         names: master
         master:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: oracle.jdbc.driver.OracleDriver
           url: jdbc:oracle:thin:@192.168.40.141:1521/fury
           username: fury
           password: fury
   
         # 初始连接数
         initialSize: 5
         # 最小连接池数量
         minIdle: 10
         # 最大连接池数量
         maxActive: 20
         # 配置获取连接等待超时的时间
         maxWait: 60000
         connectTimeout: 30000
         # 配置网络超时时间
         socketTimeout: 60000
         # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
         timeBetweenEvictionRunsMillis: 60000
         # 配置一个连接在池中最小生存的时间,单位是毫秒
         minEvictableIdleTimeMillis: 300000
         # 配置一个连接在池中最大生存的时间,单位是毫秒
         maxEvictableIdleTimeMillis: 900000
         # 配置检测连接是否有效
         validationQuery: SELECT 1 FROM DUAL
         testWhileIdle: true
         testOnBorrow: false
         testOnReturn: false
         webStatFilter:
           enabled: true
         statViewServlet:
           enabled: true
           # 设置白名单,不填则允许所有访问
           allow:
           url-pattern: /druid/*
           # 控制台管理用户名和密码
           login-username: ruoyi
           login-password: 123456
         filter:
           stat:
             enabled: true
             # 慢SQL记录
             log-slow-sql: true
             slow-sql-millis: 1000
             merge-sql: true
           wall:
             config:
               multi-statement-allow: true
       props:
         sql-show: true
       rules:
         sharding:
           default-table-strategy:
             standard:
               sharding-algorithm-name: hint-algorithm
           tables:
             sys_order:
               actual-data-nodes: master.sys_order_$->{0..1}
               table-strategy:
                 standard:
                   sharding-column: order_id
                   sharding-algorithm-name: hint-algorithm
           sharding-algorithms:
             hint-algorithm:
               type: CLASS_BASED
               props:
                 algorithmClassName: 
com.qkxx.framework.sharding.hint.TestTableAlgorithm
                 strategy: standard
     autoconfigure:
       exclude: 
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   
   ### Actual behavior
   Caused by: java.lang.NullPointerException: Properties `strategy` can not be 
null when uses class based sharding strategy.
        at 
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
        at 
org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm.getStrategy(ClassBasedShardingAlgorithm.java:66)
        at 
org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm.init(ClassBasedShardingAlgorithm.java:59)
        at 
org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.findRegisteredService(TypedSPIRegistry.java:66)
        at 
org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.getRegisteredService(TypedSPIRegistry.java:113)
        at 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory.createAlgorithm(ShardingSphereAlgorithmFactory.java:40)
        at 
org.apache.shardingsphere.sharding.factory.ShardingAlgorithmFactory.newInstance(ShardingAlgorithmFactory.java:45)
        at 
org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$new$0(ShardingRule.java:120)
        at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
        at 
org.apache.shardingsphere.sharding.rule.ShardingRule.<init>(ShardingRule.java:120)
        at 
org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:41)
        at 
org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:35)
        at 
org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:58)
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:87)
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:81)
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:69)
        at 
org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:91)
        at 
org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:69)
        at 
org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:49)
        at 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:76)
        at 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:64)
        at 
org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:93)
        at 
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.shardingSphereDataSource(ShardingSphereAutoConfiguration.java:91)
        at 
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$46ef8686.CGLIB$shardingSphereDataSource$2(<generated>)
        at 
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$46ef8686$$FastClassBySpringCGLIB$$50596d24.invoke(<generated>)
        at 
org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
        at 
org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
        at 
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$46ef8686.shardingSphereDataSource(<generated>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
        ... 130 common frames omitted
   
   ### Reason analyze 
   The strategy is missing when executing 
ShardingSphereAutoConfiguration.shardingsphereDataSource
   ### Steps to reproduce the behavior
   
![1](https://github.com/user-attachments/assets/2b99f972-9d3f-414b-9f93-8f36c8ccc8e0)
   
![2](https://github.com/user-attachments/assets/811d5162-513d-4756-8ae6-8a7584461d8f)
   
![3](https://github.com/user-attachments/assets/d18ba292-c453-4231-9ec0-cb47f863d733)
   
![4](https://github.com/user-attachments/assets/7a569c79-6e08-4e5b-bf15-ab7f6fef1e03)
   
   
   


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