alibaba/spring-cloud-alibaba · critical · IllegalStateException

NacosConfigProperties could not be loaded

Error message

NacosConfigProperties could not be loaded

What it means

Thrown by NacosConfigDataLocationResolver.resolveProfileSpecific when loadProperties(resolverContext) returns null. loadProperties binds NacosConfigProperties from the environment; a null result means the properties could not be bound at the profile-specific resolution stage, so the resolver cannot build the config-data resource list. This is the profile-specific counterpart to the 'NacosConfigProperties not available' loader error.

Source

Thrown at spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/configdata/NacosConfigDataLocationResolver.java:152

		return PREFIX;
	}

	@Override
	public List<NacosConfigDataResource> resolve(
			ConfigDataLocationResolverContext context, ConfigDataLocation location)
			throws ConfigDataLocationNotFoundException,
			ConfigDataResourceNotFoundException {
		return Collections.emptyList();
	}

	@Override
	public List<NacosConfigDataResource> resolveProfileSpecific(
			ConfigDataLocationResolverContext resolverContext,
			ConfigDataLocation location, Profiles profiles)
			throws ConfigDataLocationNotFoundException {
		NacosConfigProperties properties = loadProperties(resolverContext);
		if (properties == null) {
			throw new IllegalStateException("NacosConfigProperties could not be loaded");
		}

		ConfigurableBootstrapContext bootstrapContext = resolverContext
				.getBootstrapContext();

		bootstrapContext.registerIfAbsent(NacosConfigProperties.class,
				BootstrapRegistry.InstanceSupplier.of(properties));

		registerConfigManager(properties, bootstrapContext, resolverContext);

		return loadConfigDataResources(location, profiles, properties);
	}

	private List<NacosConfigDataResource> loadConfigDataResources(
			ConfigDataLocation location, Profiles profiles,
			NacosConfigProperties properties) {
		List<NacosConfigDataResource> result = new ArrayList<>();
		URI uri = getUri(location, properties);

View on GitHub (pinned to 115d590110)

Solutions

  1. Ensure spring.cloud.nacos.config.server-addr (and namespace/group) is bound in every profile that imports nacos: locations.
  2. Move the nacos config block to a shared location (application.yml) or duplicate it into profile-specific files.
  3. Do not exclude the Nacos config autoconfiguration when importing nacos: locations.
  4. Verify the active profile actually contains the nacos config properties.

Example fix

# before: only the default profile has nacos props, but dev imports nacos:
# application-dev.yml
spring.config.import: "nacos:app-dev.yml"
# after
spring.cloud.nacos.config.server-addr: 127.0.0.1:8848
spring.config.import: "nacos:app-dev.yml"
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the active profile binds nacos config props before profile-specific import resolution.
assert environment.getProperty("spring.cloud.nacos.config.server-addr") != null : "nacos config props required";

Prevention

When it happens

Trigger: spring.config.import has nacos: entries and a profile-specific import is being resolved, but spring.cloud.nacos.config.* is missing/unbindable so NacosConfigProperties cannot be constructed.

Common situations: Profile (e.g., application-dev.yml) imports nacos: but the nacos config block lives only in another profile or is omitted; property typos in spring.cloud.nacos.config; excluding the Nacos config autoconfiguration; version skew.

Related errors


AI-assisted analysis of alibaba/spring-cloud-alibaba@115d590110 (2026-08-14). Data as JSON: /api/errors/140cad5482c84987. Report an issue: GitHub.