Hi, If I use the spring.config.import=optional:configserver in my application.yml (and no bootstrap.yml) then I'm facing the following issue:

How can I deactivate the spring.config.import in my test classes?? It does not work with properties disabling like "spring.config.enabled=false" I need to test without configserver. Please advise

Comment From: ryanjbaxter

Did you forget to provide the issue?

Comment From: Miles-Ahead-Digital

I want to keep the TestCases and my StandardRuntime in the Spring Default Profile wich contains: spring.config.import=optional:configserver

If I run my tests (without having the config server startet), the Test fail because it tries to use the config server. But for the TestCase there is no need to get the yml-config file from the ConfigServer - it works without it..

Best regards Stefan

Comment From: ryanjbaxter

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

From my understanding that is not supposed to happen.

Comment From: Miles-Ahead-Digital

Hi,

i created https://github.com/Miles-Ahead-Digital/milesahead/tree/master

you can verify that the spring-profiles do not have any impact on the selection of the values served

Check the Readme.

Best regards Stefan

Comment From: ryanjbaxter

@Miles-Ahead-Digital Not sure I understand how this sample demonstrates the issue. Your original problem stated that you were having problem with tests failing due to the conig server not running. I don't see how this sample reproduces that problem.

Comment From: Miles-Ahead-Digital

@ryanjbaxter I added a TestCase in the Demo Module. Please read the instruction in the projects readme. Best regards Stefan

Comment From: ryanjbaxter

The problem you are having is because you are using the wrong properties in your application.yam. Change it to this and everything works

spring.application.name: demo

spring:
  config:
    import: optional:configserver:http://localhost:8888/

message: default-local

---
spring:
  config:
    activate:
      on-profile: test3

message: test3-local

---
spring:
  config:
    activate:
      on-profile: test10

message: test10-local

Comment From: Miles-Ahead-Digital

Thanks for correction. Of course this must be applied also to the files in the config-repo folder too.

The good thing is that the config server serves now the configuration as expected. Try http://localhost:8888/demo/test1 http://localhost:8888/demo/test2 http://localhost:8888/demo/test3 http://localhost:8888/demo/test4

if you start the demo service without profile the default profile config http://localhost:8888/demo/default is served correctly. Check http://localhost:8080/message.

But starting the demo service with any other profile than default we get this error:

Property 'spring.config.activate.on-profile' imported from location '[ConfigServerConfigDataResource@6d8792db uris = array['http://localhost:8888/'], optional = true, profiles = list['test4']]' is invalid in a profile specific resource

This has already been reported:

https://github.com/spring-cloud/spring-cloud-config/issues/1788

If it is the same issue, you can close this one as a duplicate.

Thanks Stefan

Comment From: ryanjbaxter

Agree appears to be the same