poo0054 opened a new issue, #18927:
URL: https://github.com/apache/shardingsphere/issues/18927
### Which version of ShardingSphere did you use?
ShardingSphere-JDBC 5.1.0 + spring boot 2.3.10
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
Slicing rules execute my own
### Actual behavior
Not initialized
### Reason analyze (If you can)
ClassBasedShardingAlgorithm not initialized,
The init() method of ClassBasedShardingAlgorithm was not executed
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
> This is my configuration
```properties
spring.shardingsphere.enabled=true
spring.shardingsphere.datasource.names=oms
spring.shardingsphere.datasource.oms.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.oms.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.oms.url=jdbc:mysql://192.168.0.128:3306/yidian_oms?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.oms.username=root
spring.shardingsphere.datasource.oms.password=root
spring.shardingsphere.rules.sharding.tables.oms_master_order.actual-data-nodes=oms.oms_master_order_$->{0..1}
spring.shardingsphere.rules.sharding.tables.oms_master_order.table-strategy.standard.sharding-column=id
spring.shardingsphere.rules.sharding.tables.oms_master_order.table-strategy.standard.sharding-algorithm-name=master-order-inline
spring.shardingsphere.rules.sharding.sharding-algorithms.master-order-inline.type=CLASS_BASED
spring.shardingsphere.rules.sharding.sharding-algorithms.master-order-inline.props=strategy
spring.shardingsphere.rules.sharding.sharding-algorithms.master-order-inline.props.algorithmClassName=cn.dian1.oms.core.sharding.TableShardingAlgorithm
```
> This is my Algorithm
```java
@Component
public class TableShardingAlgorithm implements
StandardShardingAlgorithm<Long> {
@Override
public String doSharding(Collection<String> availableTargetNames,
PreciseShardingValue<Long> shardingValue) {
System.out.println(availableTargetNames + "----------------" +
availableTargetNames);
return null;
}
@Override
public Collection<String> doSharding(Collection<String>
availableTargetNames, RangeShardingValue<Long> shardingValue) {
System.out.println(availableTargetNames + "----------------" +
availableTargetNames);
return null;
}
@Override
public void init() {
System.out.println("------------------------------自定义分片启动----------------------------");
}
@Override
public String getType() {
return "";
}
}
```
When executing classbasedshardingalgorithm. The attribute props in it has
value, but standardshardingalgorithm is empty,
I looked at the classbasedshardingalgorithm and did not execute its init ()
method after startup.
The initialization of my customized method has not been executed
### Example codes for reproduce this issue (such as a github link).
--
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]