方便更快捷的说明问题,可以按需填写(可删除)
使用环境:
shardingsphere5.2.0
场景、问题:
@Slf4j
public class CloudHintShardingAlgorithm implements HintShardingAlgorithm {
// 分表数量
private static int tableSize;
private Properties props=new Properties();
@Value("${tableSize}")
public void setTableSize(int size) {
tableSize = size;
}
public CloudHintShardingAlgorithm(){
}
List<String> tcloudIds = Lists.newArrayList();
@Override
public Collection<String> doSharding(Collection<String> availableTargetNames, HintShardingValue<String> shardingValue) {
List<String> result = Lists.newArrayList();
/* Random random = new Random();
Integer t = random.nextInt(10);
if(t%2 == 0){
result.add(“sharding0”);
}else{
result.add(“sharding1”);
}*/
result.add(“sharding1”);
return result;
}
已进行操作:
现状:
tableSize 无法注入
由于最新版本的5.2是不能在CloudHintShardingAlgorithm 加注解@Component,是由shardingsphere直接进行初始化并注入到spring中,请问如何进行外部参数注入