zhchhawks commented on issue #23768:
URL:
https://github.com/apache/shardingsphere/issues/23768#issuecomment-1425147374
I use java API in my old frame project like this without spring boot :
` ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
shardingRuleConfig.getTables().add(getXxxTableRuleConfigurationNb());
shardingRuleConfig.getBindingTableGroups()
.add(new ShardingTableReferenceRuleConfiguration(SHARDING_KEY,
SHARDING_TABLE_LIST));
shardingRuleConfig.setDefaultShardingColumn(SHARDING_KEY);
Properties tableShardingAlgorithmrProps = new Properties();
tableShardingAlgorithmrProps.setProperty("strategy", "STANDARD");
tableShardingAlgorithmrProps.setProperty("algorithmClassName",
"Algorithm class getName");
shardingRuleConfig.getShardingAlgorithms()
.put(ALGORITHM_NAME,
new AlgorithmConfiguration("CLASS_BASED",
tableShardingAlgorithmrProps));
shardingRuleConfig.setDefaultTableShardingStrategy(new
StandardShardingStrategyConfiguration(
SHARDING_KEY, ALGORITHM_NAME));
ModeConfiguration modeConfiguration = new
ModeConfiguration("Standalone",
new StandalonePersistRepositoryConfiguration("JDBC", new
Properties()));
return
ShardingSphereDataSourceFactory.createDataSource(modeConfiguration,
createDataSourceMap(),
Collections.singleton(shardingRuleConfig), new Properties());`
--
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]