问题如题,提前做了sentinel控制台的推模式集成nacos,客户端也配置了nacos动态数据源,但是看日志规则没拉下来,日志中发现是去接口拉规则的时候没有tenant参数导致找不到配置文件(因为我的控制台把规则推送到了指定命名空间下,不是公共命名空间)。
2022-02-28 18:36:16.893 DEBUG 12600 --- [ main] s.n.www.protocol.http.HttpURLConnection : sun.net.www.MessageHeader@79627d2712 pairs: {GET /nacos/v1/cs/configs?dataId=spring-cloud-sentinel-sample-param-rules&group=SENTINEL_GROUP HTTP/1.1: null}{exConfigInfo: true}{RequestId: 212e61e4-5fd4-4a5f-8252-6a342eda900d}{Client-Version: 1.1.4}{Content-Type: application/x-www-form-urlencoded;charset=UTF-8}{Client-AppName: spring-cloud-sentinel-sample}{Client-RequestTS: 1646044576893}{Client-RequestToken: 926718a15304aa3b88ef797e2e2c2e43}{User-Agent: Java/17.0.1}{Host: 192.168.20.133:8848}{Accept: text/html, image/gif, image/jpeg, *; q=.2, *
public class NacosDataSourceFactoryBean implements FactoryBean {
private String serverAddr;
private String groupId;
private String dataId;
private Converter converter;
private String endpoint;
private String namespace;
private String accessKey;
private String secretKey;
@Override
public NacosDataSource getObject() throws Exception {
Properties properties = new Properties();
if (!StringUtils.isEmpty(this.serverAddr)) {
properties.setProperty(PropertyKeyConst.SERVER_ADDR, this.serverAddr);
}
else {
properties.setProperty(PropertyKeyConst.ACCESS_KEY, this.accessKey);
properties.setProperty(PropertyKeyConst.SECRET_KEY, this.secretKey);
properties.setProperty(PropertyKeyConst.ENDPOINT, this.endpoint);
}
if (!StringUtils.isEmpty(this.namespace)) {
properties.setProperty(PropertyKeyConst.NAMESPACE, this.namespace);
}
return new NacosDataSource(properties, groupId, dataId, converter);
}
@Override
public Class> getObjectType() {
return NacosDataSource.class;
}
public String getServerAddr() {
return serverAddr;
}
public void setServerAddr(String serverAddr) {
this.serverAddr = serverAddr;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
public Converter getConverter() {
return converter;
}
public void setConverter(Converter converter) {
this.converter = converter;
}
public String getEndpoint() {
return endpoint;
}
public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}
public String getNamespace() {
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
}
public String getAccessKey() {
return accessKey;
}
public void setAccessKey(String accessKey) {
this.accessKey = accessKey;
}
public String getSecretKey() {
return secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
}



