spring-cloud-config icon indicating copy to clipboard operation
spring-cloud-config copied to clipboard

wrong property value

Open mousavi007 opened this issue 1 year ago • 2 comments

i use spring config server and that work great. my problem is when run client in docker profile to get config from config server, uri properties for spring.cloud.config not set correctly. this is my application.yml:

spring.config.import: configserver:"

spring:
  application.name: product
  cloud.config:
    failFast: true
    retry:
      initialInterval: 3000
      multiplier: 1.3
      maxInterval: 10000
      maxAttempts: 20
    uri: http://localhost:8888
    username: ${CONFIG_SERVER_USR}
    password: ${CONFIG_SERVER_PWD}

---
spring.config.activate.on-profile: docker

spring.cloud.config.uri: http://config-server:8888

if i run client in default profile, it's run correctly, but if i run client in docker profile it get net error because property not set to docker profile and set to default profile. and this is docker compose file:

services:
  product:
    build: product-service
    mem_limit: 512m
    environment:
      - SPRING_PROFILES_ACTIVE=docker
      - CONFIG_SERVER_USR=${CONFIG_SERVER_USR}
      - CONFIG_SERVER_PWD=${CONFIG_SERVER_PWD}
    depends_on:
      mongodb:
        condition: service_healthy
      rabbitmq:
        condition: service_healthy

mousavi007 avatar May 20 '24 20:05 mousavi007

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.

ryanjbaxter avatar May 22 '24 20:05 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.

the problem is that when i run project with default profile, it's good and uri is http://localhost:8888. but when i run project in docker and used docker profile, the uri yet still is http://localhost:8888 but i set it to http://config-server:8888 in docker profile in source code.

mousavi007 avatar May 23 '24 11:05 mousavi007

Looking more closely at your configuration, it seems a but off to me. You are using spring.config.import and spring.cloud.config.uri. You should choose one or the other approach. If you using spring.config.import you should be aware that it cannot be overriden in profile specific documents, you will need to set the config server host in a separate property and reference that property in spring.config.import and override it in the profile specific document.

ryanjbaxter avatar Jul 01 '24 18:07 ryanjbaxter

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-cloud-issues avatar Jul 08 '24 18:07 spring-cloud-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-cloud-issues avatar Jul 15 '24 18:07 spring-cloud-issues

same issue here

twosom avatar Oct 12 '24 16:10 twosom

Here is my solution

---
spring.config.import: "optional:configserver"
spring:
  application.name: "auth-server"
  cloud.config:
    failFast: true
    retry:
      initialInterval: 3000
      multiplier: 1.3
      maxInterval: 10000
      maxAttempts: 20
    uri: "http://localhost:8888"
    username: "${CONFIG_SERVER_USR}"
    password: "${CONFIG_SERVER_PWD}"
---
spring.config.activate.on-profile: "docker"
spring.cloud.config.uri: "http://config-server:8888"
spring.config.import: "configserver:${spring.cloud.config.uri}"

twosom avatar Oct 12 '24 18:10 twosom