spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.95k stars 1.29k forks source link

wrong property value #2420

Closed mousavi007 closed 2 months ago

mousavi007 commented 4 months ago

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
ryanjbaxter commented 4 months ago

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.

mousavi007 commented 4 months ago

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.

ryanjbaxter commented 3 months ago

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.

spring-cloud-issues commented 2 months ago

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 commented 2 months ago

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.