Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling config server for tests

I am using microservice architecture where the services are done with spring boot, to control them, I am using zuul as a proxy, eureka as register and config server as the configuration provider.

In the microservices I configure my bootstrap.yml file as follows:

spring:
  application:
    name: portal-gca-server-${MYENV:local}
  cloud:
    config:
      uri: http://localhost:9090

As seen above, the config file name that I look for in the config server is according to my environment variable, otherwise I get the local profile. This works fine, but when I run the tests on the development machine it will never work, because instead of searching for the test profile it searches for the location, because the dev machine has no environment variable. I know I could register the environment variable to run the tests but that's not the intention or else I would have to do this all the time to run tests and to run the local application.

Is there any way to solve this? I already tried to use the annotations:

webEnvironment = SpringBootTest.WebEnvironment.MOCK
@ActiveProfiles("test")
@TestPropertySource(locations="classpath:application-test.properties")

None of them any good, because the first thing the application does when executed is to fetch the information in git according to bootstrap.yml.

Has anyone ever experienced this?

like image 269
felipe cesar Avatar asked Dec 28 '25 19:12

felipe cesar


1 Answers

Go to your bootstrap.yml and then add :

spring:
  cloud:
    config:
     enabled: false
like image 157
Sergei Golitsyn Avatar answered Dec 31 '25 18:12

Sergei Golitsyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!