williamXinCC opened a new issue, #18721:
URL: https://github.com/apache/shardingsphere/issues/18721
my key generator
@Slf4j
public final class SeeingflowKeyGenerator implements KeyGenerateAlgorithm{
private Properties properties = new Properties();
@Override
public String getType() {
return "SeeingflowKeyGenerator";
}
// @Override
// public synchronized Comparable<?> generateKey() {
// GenerationFeginClient generationFeginClient =
SpringUtil.getBean(GenerationFeginClient.class);
// return generationFeginClient.getKey();
// }
@Override
public synchronized String generateKey() {
System.out.println("==================generateKey=====================");
GenerationFeginClient generationFeginClient =
SpringUtil.getBean(GenerationFeginClient.class);
return generationFeginClient.getKey();
}
@Override
public Properties getProps() {
System.out.println("getProps=======================================SeeingflowKeyGenerator");
return properties;
}
@Override
public void init(Properties properties) {
System.out.println("初始化=======================================SeeingflowKeyGenerator");
}
config
shardingRuleConfig.setDefaultKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id","SeeingflowKeyGenerator"));
shardingRuleConfig.getKeyGenerators().put("SeeingflowKeyGenerator",
new
ShardingSphereAlgorithmConfiguration("SeeingflowKeyGenerator", null));
mybatis-plus po
public class EventsLog implements Serializable {
private static final long serialVersionUID = 1L;
// @TableId(value = "id",type = IdType.Auto)
@ApiModelProperty(value = "事件id")
private String id;
log alert
2022-06-30 11:52:41.742 INFO 22732 --- [ main]
o.s.s.c.ThreadPoolTaskExecutor : Initializing ExecutorService
'applicationTaskExecutor'
2022-06-30 11:52:41.839 INFO 22732 --- [ main]
o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService
'Nacos-Watch-Task-Scheduler'
====================getKeyGenerators====================
{
"SeeingflowKeyGenerator": {
"type": "SeeingflowKeyGenerator",
"props": {
}
}
}
2022-06-30 11:52:42.846 INFO 22732 --- [ main]
c.a.d.p.DruidDataSource : {dataSource-1,db1} inited
2022-06-30 11:52:43.948 INFO 22732 --- [ main]
c.a.d.p.DruidDataSource : {dataSource-2,db0} inited
2022-06-30 11:52:44.142 INFO 22732 --- [ main]
c.a.d.p.DruidDataSource : {dataSource-3,db2} inited
Spi has bean loaded
So,how to use customer key generator?
mybatis-plus 3.4.3
shardingsphere 5.1.2
--
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]