com.alibaba.cloud spring-cloud-alibaba-dependencies2.2.2.RELEASE pom import
org.springframework.boot spring-boot-starter-webcom.alibaba.cloud spring-cloud-starter-alibaba-sentinelcom.alibaba.csp sentinel-datasource-nacos
org.springframework.boot spring-boot-starter-parent2.3.1.RELEASE
@PostConstruct
public void init2() {
Properties properties = new Properties();
properties.put(PropertyKeyConst.SERVER_ADDR, "192.168.1.1:8849");
properties.put(PropertyKeyConst.NAMESPACE, "public");
properties.put("username", "nacos");
properties.put("password", "nacos");
String groupId = "DEFAULT_GROUP";
String dataId = "test-sentinel";
ReadableDataSource> flowRuleDataSource = new NacosDataSource<>(properties, groupId, dataId,
source -> JSON.parseObject(source, new TypeReference>() {
}));
SentinelProperty> property = flowRuleDataSource.getProperty();
FlowRuleManager.register2Property(property);
}
nacos版本:nacos/nacos-server:2.0.2
sentinel版本:java -Dserver.port=8083 -jar sentinel-dashboard-1.8.2.jar



