0

why is the new spring-cloud-config so complicated?

I would like to do the following: enable eureka on default and add it in some profiles (not in all).
no matter in which way I tried it, it didn't work.
I get this error Failed to bind properties under 'eureka.client.enabled' to boolean.

first way:

server:
  port: 8080

eureka:
  client:
    enabled: false # default disabled
  instance:
    leaseRenewalIntervalInSeconds: 10
    prefer-ip-address: false
    hostname: 127.0.0.1

spring:
  application:
    name: app
  main:
    banner-mode: off
  cloud:
    config:
      enabled: false
      discovery:
        enabled: true
        service-id: config-server
      fail-fast: true
      retry:
        max-attempts: 5

application:
  value: app-default

---

spring:
  config:
    activate:
      on-profile: dev

application:
  value: app-dev

---

spring:
  config:
    activate:
      on-profile: qa
    import: "configserver:"
  cloud:
    config:
      enabled: true

eureka:
  client:
    enabled: true # enable it in profile "qa"
    serviceUrl:
      defaultZone: http://127.0.0.1:8761/eureka/

application:
  value: app-qa

second way:

server:
  port: 8080

eureka:
  client:
    enabled: true # default enabled
  instance:
    leaseRenewalIntervalInSeconds: 10
    prefer-ip-address: false
    hostname: 127.0.0.1

spring:
  application:
    name: app
  main:
    banner-mode: off
  cloud:
    config:
      enabled: false
      discovery:
        enabled: true
        service-id: config-server
      fail-fast: true
      retry:
        max-attempts: 5

application:
  value: app-default

---

spring:
  config:
    activate:
      on-profile: dev

eureka:
  client:
    enabled: false # disable in profile "dev"

application:
  value: app-dev

---

spring:
  config:
    activate:
      on-profile: qa
    import: "configserver:"
  cloud:
    config:
      enabled: true

eureka:
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8761/eureka/ # I also need a profile specific url

application:
  value: app-qa

if I activate eureka once and never use eureka.client.enabled again, then the error with the url occurs: Failed to bind properties under 'eureka.client.serviceUrl. defaultZone' to String - but I need this profile specific url in any case!

all this has to do with the new spring-cloud-config. because after I deleted all the lines for the config-server and commented out the spring-cloud-starter-config dependency, both variants with eureka worked!
or do i have an error according to this spring-cloud-config stuff?

versions:

    <spring-boot.version>2.5.2</spring-boot.version>
    <spring-cloud.version>2020.0.3</spring-cloud.version>
m1well
  • 716
  • 4
  • 15
  • 28
  • Looking for a way to disable eureka client registration based on profile? – fatih Jul 31 '21 at 07:03
  • yes exactly. with the "old" config server the works fine. but with the new one not – m1well Jul 31 '21 at 12:03
  • What version of spring cloud are you using? – fatih Jul 31 '21 at 16:57
  • I added them in the initial post. but I mean the `import: "configserver:"` indicates a very new version – m1well Aug 01 '21 at 06:49
  • Are you using the `@EnableDiscoveryClient` annotation? I think the answers [here](https://stackoverflow.com/questions/35142105/how-to-selectively-disable-eureka-discovery-client-with-spring) can help you. – fatih Aug 01 '21 at 06:54
  • that is not the problem. in your post there is also a hint for `eureka.client.enabled = false`. I have narrowed it down further that I need also a `default` profile on my default values on top of the file. then the application starts. but the values from the config server are not invoked... – m1well Aug 01 '21 at 07:49
  • Is your problem that your application does not start with your values in config-server? – fatih Aug 01 '21 at 10:26
  • after long researches and tests -> my problem now is: I can't provide multiple eureka urls in one application.yml file (for different profiles) – m1well Aug 03 '21 at 13:03

0 Answers0