cedar0822 commented on issue #32778:
URL:
https://github.com/apache/shardingsphere/issues/32778#issuecomment-2328238544
您好,这个问题我降到5.2.0版本解决了。但是又有一个新问题,我是springboot项目,本地启动是正常的,但是打成war包放到服务器Tomcat上后启动报错:
Failed to get driver instance for
jdbcUrl=jdbc:h2:mem:config;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
private void initShardingDataSources(Environment env) throws SQLException {
String dataname = "sharding";
Map<String, DataSource> dataSourceMap = new HashMap<>();
DruidDataSource dataSourceWrite = new DruidDataSource();
dataSourceWrite.setDriverClassName(env.getProperty("spring.datasource.druid.driver-class-name"));
dataSourceWrite.setUrl(env.getProperty("spring.datasource.url"));
dataSourceWrite.setUsername(env.getProperty("spring.datasource.username"));
dataSourceWrite.setPassword(env.getProperty("spring.datasource.password"));
dataSourceMap.put(dataname, dataSourceWrite);
slaveDataSources.put(dataname, shardingDataSource(dataSourceMap));
}
DataSource shardingDataSource(Map<String, DataSource> dataSourceMap)
throws SQLException {
Properties props = new Properties();
props.setProperty("sql-show", Boolean.TRUE.toString());
props.setProperty("provider","MySQL");
DruidDataSource sharding = (DruidDataSource) dataSourceMap.get("sharding");
props.setProperty("jdbc_url", sharding.getDriverClassName());
props.setProperty("username", sharding.getUsername());
props.setProperty("password", sharding.getPassword());
Collection<RuleConfiguration> ruleConfigs = new ArrayList<>();
ShardingRuleConfiguration shardingRuleConfig = new
ShardingRuleConfiguration();
shardingRuleConfig.getBindingTableGroups().add("gift_send_record");
shardingRuleConfig.setDefaultTableShardingStrategy(new
StandardShardingStrategyConfiguration("create_time", "tb-sharding-algorithm"));
shardingRuleConfig.getTables().add(getGiftSendRecordTableRuleConfiguration());
shardingRuleConfig.getTables().add(getGiftTableRuleConfiguration());
shardingRuleConfig.setShardingAlgorithms(getShardingAlgorithms());
// 内置Snowflake分布式序列算法配置
Properties snowflakeProp = new Properties();
snowflakeProp.setProperty("worker-id", "1");
shardingRuleConfig.getKeyGenerators().put("snowflake",
new AlgorithmConfiguration("SNOWFLAKE", snowflakeProp));
ruleConfigs.add(shardingRuleConfig);
ModeConfiguration modeConfiguration = new ModeConfiguration("Standalone",
new StandalonePersistRepositoryConfiguration("JDBC", props),false);
DataSource dataSource =
ShardingSphereDataSourceFactory.createDataSource(modeConfiguration,dataSourceMap,
ruleConfigs, props);
return dataSource;
}
At 2024-09-03 08:23:30, "comecny" ***@***.***> wrote:
A single table does not require a configuration rule, or you can set a fixed
rule instead of a dynamic one. I see that your rule uses the creation time for
sharding.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
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]