spring-cloud / spring-cloud/spring-cloud-consul

Commas in spring.config.import split config data location rather than act as profile separator

Open
#701 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Java
Stars
822
Forks
539
Avg merge
9h 31m
Merged PRs (30d)
7

Description

Hi

I tried to use Spring Config Import feature that appeared in Spring Boot 2.4. It works fine without Spring profiles but if I tried to use a profile then errors are present.

The documentation for Spring Cloud Consul Config states that if you want to use profiles you should create similar folders structure in Consul:

config/testApp,dev/
config/testApp/
config/application,dev/
config/application/

I want to use default and prod profiles in my Spring Boot application. So I created two root folders in Consul:

  • app
  • app,prod

If I try to specify app and app,prod folder in my application-prod.yml:

spring:
  config:
    import: "consul:localhost:8500;app;app,prod"

Then I get the exceptions:

java.lang.IllegalStateException: Unable to load config data from 'prod'
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:125)
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/'
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferencesForFile(StandardConfigDataLocationResolver.java:200)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.getReferences(StandardConfigDataLocationResolver.java:122)

If omit the last folder:

spring:
  config:
    import: "consul:localhost:8500;app"

then configuration is loaded properly. Please advise on this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the import in application-prod.yml with both app and app,prod Consul locations. Read the failure path named in StandardConfigDataLocationResolver.java and compare it with the documented Consul folder structure. Done means comma-containing locations are treated as intended profile paths and the existing single-location case still loads correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.