diff --git a/sentinel-dashboard/pom.xml b/sentinel-dashboard/pom.xml index 3e3fb417..3a39e453 100755 --- a/sentinel-dashboard/pom.xml +++ b/sentinel-dashboard/pom.xml @@ -135,11 +135,12 @@ 1.16.1 test - + diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosConfiguration.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosConfiguration.java index 7843444f..3b3d9503 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosConfiguration.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosConfiguration.java @@ -31,10 +31,9 @@ import java.util.List; import java.util.Properties; @Configuration -@EnableConfigurationProperties(NacosConfigurationProperties.class) +@EnableConfigurationProperties(NacosProperties.class) public class NacosConfiguration { - @Bean public Converter, String> flowRuleEntityEncoder() { return JSON::toJSONString; @@ -46,7 +45,7 @@ public class NacosConfiguration { } @Bean - public ConfigService nacosConfiguration(NacosPropertiesConfiguration nacosPropertiesConfiguration) throws NacosException { + public ConfigService nacosConfiguration(NacosProperties nacosPropertiesConfiguration) throws NacosException { Properties properties = new Properties(); properties.put(PropertyKeyConst.SERVER_ADDR,nacosPropertiesConfiguration.getServerAddr()); properties.put(PropertyKeyConst.NAMESPACE,nacosPropertiesConfiguration.getNamespace()); diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosPropertiesConfiguration.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosProperties.java similarity index 89% rename from sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosPropertiesConfiguration.java rename to sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosProperties.java index 9f9c51ba..11a6edda 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosPropertiesConfiguration.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/NacosProperties.java @@ -15,17 +15,13 @@ */ package com.alibaba.csp.sentinel.dashboard.config; -import org.springframework.beans.factory.annotation.Configurable; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; /** * @author King Wang */ -@Component -@Configurable @ConfigurationProperties(prefix="sentinel.nacos") -public class NacosPropertiesConfiguration { +public class NacosProperties { private String serverAddr; private String dataId; diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosProvider.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosProvider.java index bdf8284c..19b5a882 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosProvider.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosProvider.java @@ -16,7 +16,7 @@ package com.alibaba.csp.sentinel.dashboard.rule; import com.alibaba.csp.sentinel.dashboard.common.NacosConstants; -import com.alibaba.csp.sentinel.dashboard.config.NacosPropertiesConfiguration; +import com.alibaba.csp.sentinel.dashboard.config.NacosProperties; import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.datasource.Converter; import com.alibaba.nacos.api.config.ConfigService; @@ -37,14 +37,14 @@ public class FlowRuleNacosProvider implements DynamicRuleProvider> converter; @Override public List getRules(String appName) throws Exception { String dataId=new StringBuilder(appName).append(NacosConstants.DATA_ID_POSTFIX).toString(); - String rules = configService.getConfig(dataId,nacosPropertiesConfiguration.getGroupId(),3000); + String rules = configService.getConfig(dataId,nacosProperties.getGroupId(),3000); //log.info("pull FlowRule from nacos Config:"+rules); if (rules.isEmpty()) { return new ArrayList<>(); diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosPublisher.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosPublisher.java index a89e06fa..a779ae02 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosPublisher.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleNacosPublisher.java @@ -16,7 +16,7 @@ package com.alibaba.csp.sentinel.dashboard.rule; import com.alibaba.csp.sentinel.dashboard.common.NacosConstants; -import com.alibaba.csp.sentinel.dashboard.config.NacosPropertiesConfiguration; +import com.alibaba.csp.sentinel.dashboard.config.NacosProperties; import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.datasource.Converter; import com.alibaba.csp.sentinel.util.AssertUtil; @@ -37,7 +37,7 @@ public class FlowRuleNacosPublisher implements DynamicRulePublisher,String> converter; @@ -49,6 +49,6 @@ public class FlowRuleNacosPublisher implements DynamicRulePublisher