Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext-config 中配置无法单独生效 #329

Open
xieshenace opened this issue Apr 27, 2024 · 1 comment
Open

ext-config 中配置无法单独生效 #329

xieshenace opened this issue Apr 27, 2024 · 1 comment

Comments

@xieshenace
Copy link

xieshenace commented Apr 27, 2024

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.6.7</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>nacos-config-spring-boot-starter</artifactId>
    <version>0.2.12</version>
  </dependency>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
  </dependency>
image image 可以获取到; 但是: image

必须要在根目录有data-id后,才能再ext-config 中配置其他配置;

我的需求是:会有不同组的不统配置,但是这样就不能完全写在ext-config中了。

@fishandsheep
Copy link

看代码根目录data-iddata-ids必须定义其中一个,否则报错,建议nacos配置中心定义一个根目录下的data-id对应的文件,空的也行

	private List<NacosPropertySource> reqGlobalNacosConfig(ConfigurableEnvironment environment, Properties globalProperties,
			NacosConfigProperties nacosConfigProperties) {
		List<String> dataIds = new ArrayList<>();
		// Loads all data-id information into the list in the list
		if (!StringUtils.hasLength(nacosConfigProperties.getDataId())) {
			final String ids = environment
					.resolvePlaceholders(nacosConfigProperties.getDataIds());
			if(StringUtils.hasText(ids)){
				dataIds.addAll(Arrays.stream(ids.split(","))
						.filter(StringUtils::hasText)
						.collect(Collectors.toList()));
			}
		}
		else {
			dataIds.add(nacosConfigProperties.getDataId());
		}
		final String groupName = environment
				.resolvePlaceholders(nacosConfigProperties.getGroup());
		final boolean isAutoRefresh = nacosConfigProperties.isAutoRefresh();
		return new ArrayList<>(Arrays.asList(reqNacosConfig(environment, globalProperties,
				dataIds.toArray(new String[0]), groupName, nacosConfigProperties.getType(), isAutoRefresh)));
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants