Skip to content

Commit cde3f54

Browse files
WweieiAias00
andauthored
fix:ShenyuBootstrapApplication run failed when using Nacos data sync (apache#6124)
* fix:ShenyuBootstrapApplication run failed when using Nacos data sync * fix:checkstyle error in NacosSyncDataConfiguration --------- Co-authored-by: aias00 <liuhongyu@apache.org>
1 parent 0184d4b commit cde3f54

File tree

2 files changed

+9
-6
lines changed
  • shenyu-infra/shenyu-infra-nacos/src/main/java/org/apache/shenyu/infra/nacos/autoconfig
  • shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-nacos/src/main/java/org/apache/shenyu/springboot/starter/sync/data/nacos

2 files changed

+9
-6
lines changed

shenyu-infra/shenyu-infra-nacos/src/main/java/org/apache/shenyu/infra/nacos/autoconfig/ConditionOnSyncNacos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import java.lang.annotation.Target;
2828

2929
/**
30-
* Enable etcd data sync.
30+
* Enable nacos data sync.
3131
*/
3232

3333
@Target({ElementType.TYPE, ElementType.METHOD})

shenyu-spring-boot-starter/shenyu-spring-boot-starter-sync-data-center/shenyu-spring-boot-starter-sync-data-nacos/src/main/java/org/apache/shenyu/springboot/starter/sync/data/nacos/NacosSyncDataConfiguration.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.lang3.StringUtils;
2424
import org.apache.shenyu.common.config.ShenyuConfig;
2525
import org.apache.shenyu.infra.nacos.autoconfig.ConditionOnSyncNacos;
26+
import org.apache.shenyu.infra.nacos.autoconfig.NacosProperties;
2627
import org.apache.shenyu.infra.nacos.config.NacosConfig;
2728
import org.apache.shenyu.sync.data.api.AuthDataSubscriber;
2829
import org.apache.shenyu.sync.data.api.DiscoveryUpstreamDataSubscriber;
@@ -35,6 +36,7 @@
3536
import org.slf4j.LoggerFactory;
3637
import org.springframework.beans.factory.ObjectProvider;
3738
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
39+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3840
import org.springframework.context.annotation.Bean;
3941
import org.springframework.context.annotation.Configuration;
4042

@@ -50,6 +52,7 @@
5052
@Configuration
5153
@ConditionOnSyncNacos
5254
@ConditionalOnClass({NacosSyncDataService.class, ConfigService.class})
55+
@EnableConfigurationProperties(NacosProperties.class)
5356
public class NacosSyncDataConfiguration {
5457

5558
private static final Logger LOGGER = LoggerFactory.getLogger(NacosSyncDataConfiguration.class);
@@ -112,14 +115,14 @@ public ConfigService nacosConfigService(final NacosConfig nacosConfig) throws Ex
112115
}
113116

114117
/**
115-
* Http config.
118+
* nacos config.
116119
*
117-
* @return the http config
120+
* @param nacosProperties the nacos properties
121+
* @return the nacos config
118122
*/
119123
@Bean
120124
@ConditionOnSyncNacos
121-
public NacosConfig nacosConfig() {
122-
123-
return NacosConfig.builder().build();
125+
public NacosConfig nacosConfig(final NacosProperties nacosProperties) {
126+
return nacosProperties.getNacos();
124127
}
125128
}

0 commit comments

Comments
 (0)