GithubHelp home page GithubHelp logo

Comments (25)

spencergibb avatar spencergibb commented on May 24, 2024 4

@btiernay That is currently how `application.[properties|yml] is shared across all applications using config server.

from spring-cloud-config.

shashanksinghal avatar shashanksinghal commented on May 24, 2024 4

@dsyer Thanks for the prompt response. I actually got it working just now. So I am not sure the behaviour I am seeing is a bug or its intended (and should be put in doc in that case)

My application.yml now looks like:

server:
  port: 8888

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: classpath:config/,classpath:config/global.yml

What is happening currently is that what I put in global.yml is seen across all clients. In the config folder I can put ymls as {application-name}.yml and its seen by that application only.

Even if its not intended I am happy for now and hope it remains same :-)

I am on spring-cloud-config-server v1.1.0.M3 (through spring cloud Brixton M3)

Thanks again!

from spring-cloud-config.

ssindelar avatar ssindelar commented on May 24, 2024 2

It would be nice to better describe it in the documentation. It is only very short described in brackets in the config under "Environment Repository". Also it should be noted that when a use a file-system backed config server the application.yml/properties needs to be in a seperate folger (/config is default) to work. If you put it in root it is used in the configserver but not shared with the clients.

from spring-cloud-config.

ryanjbaxter avatar ryanjbaxter commented on May 24, 2024 1

I don't think its too much of a concern, it is just a warning. If you want you might be able to adjust things using Spring Profiles so only certain configuration properties are set.

from spring-cloud-config.

btiernay avatar btiernay commented on May 24, 2024

My apologies then. Thats great :)

from spring-cloud-config.

shashanksinghal avatar shashanksinghal commented on May 24, 2024

Hi @ssindelar,

I am also trying to achieve what you mentioned in your last comment. By file-system backed config server I assume you mean 'spring.profiles.acive: native'. I want some shared config and some service specific config. As you suggested I created an 'application.yml' under src/main/resources i.e. config folder is at classpath. The client does not picks that up.

from spring-cloud-config.

dsyer avatar dsyer commented on May 24, 2024

@shashanksinghal the "native" profile excludes all property sources that occur in the server itself. I suggest you use a local git repository if you need this feature in a local repo.

from spring-cloud-config.

dsyer avatar dsyer commented on May 24, 2024

Yeah that would work.

from spring-cloud-config.

ssindelar avatar ssindelar commented on May 24, 2024

@shashanksinghal sorry for the late answer. It put the files outside the jar because inside the jar they don't make sense, because the whole point is that you can edited them on the fly. I also used .properties instead of .yml, maybe there is also a different. {workingdir}/config is not picked up by the normal scan for properties/yml files.

from spring-cloud-config.

dinkarthakur avatar dinkarthakur commented on May 24, 2024

Hi I'm aslo in same problem with Brixton.M4 and

spring:
  profiles:
    active: native 

if i create application.yml in /config folder inside resources in spring config server its not shared and if i use application.properties it get shared. Is this a bug?

from spring-cloud-config.

dsyer avatar dsyer commented on May 24, 2024

It might be a bug if it shares application.properties (since that should be used by the config server app itself), unless you mean you added it after start up. Can you provide a sample project?

from spring-cloud-config.

dinkarthakur avatar dinkarthakur commented on May 24, 2024

i have to add

spring:
  application:
    name: config-server
  profiles:
    include: native
  cloud:
    config:
      server:
        native:
          search-locations: classpath:config/

to make it work even when the config folder is in BuildPath
also i found some odd behaviour like
if i use appplication.properties then the sequence in which properties from {application}.property and common appplication.properties are picked is diifferent if i use yml

also if i use @project.artifactId@ to get value from the mvn in common application.properties then it always shows the value from pom.xml of config server
and if i add @project.artifactId@ to application specific {application}.yml/.property in config server then its value is not calculated

and if i add
logging.file= ${spring.application.name} to the common application.properties in config server its fails to start with ex Could not resolve placeholder 'spring.application.name' in string value "${spring.application.name}"
sample app is at https://github.com/dinkarthakur/spring-cloud-sample.git

from spring-cloud-config.

dsyer avatar dsyer commented on May 24, 2024

Placeholders with "@" are a maven feature (so part of your build). Take those out of the equation and open a new issue if you have some ordering questions.

from spring-cloud-config.

cesargomezvela avatar cesargomezvela commented on May 24, 2024

In response to the main topic:
"Add spring-cloud-config-server ability to share common configuration across applications"

Now you can add a general application.yml to share common configuration across applications.
I found the response here:
http://stackoverflow.com/questions/35555232/loading-multiple-properties-with-config-server?answertab=votes#tab-top

I paste the response in case you don't want to follow the link:

You can create a general application.yml in the root folder of SVN.
See the example config repo here: https://github.com/spring-cloud-samples/config-repo
And here is an example consumer https://github.com/spring-cloud-samples/customers-stores/blob/master/rest-microservices-store/src/main/resources/bootstrap.yml

The customer-stores project will read from application.yml and also from stores.yml in the repo.

To confirm, check the /env URL if you have actuator added and you should see two configService entries

from spring-cloud-config.

hodeh avatar hodeh commented on May 24, 2024

a really great feature , but I have a question. in application-dev.yml / application-test.yml /application-prod.yml I want to include configurations for the infrastructure so I dont repeat it in each service , things like hosts/usernames/passwords for ( zipkin,eureka,mysql,cassandra,rabbit,redis)

the question here is that I dont want to pull all configurations in that file , i mean some services might use MySQL configs and not Cassandra , is there something out of the box to do it or maybe i have to develop custom PropertySourcesPlaceholderConfigurer to exclude some configs based on custom property in that the service to allow it to filter only the required technology configs required by that service.

from spring-cloud-config.

ryanjbaxter avatar ryanjbaxter commented on May 24, 2024

What is the concern with a client pulling down some configuration it doesnt use?

from spring-cloud-config.

hodeh avatar hodeh commented on May 24, 2024

@ryanjbaxter I have a concern that might not be valid, the client (Spring Boot Service) may complain if it found configs for a library that it is not found on the class path.
example : the client found a property for spring.datasource.url and the client doest have any dependency declared in the pom for spring-boot-starter-data-jpa , should I worry about that ?

from spring-cloud-config.

emedina avatar emedina commented on May 24, 2024

@ryanjbaxter I don't agree with you. Setting properties not required for an application, like DB URLs or URLs to external services which include authentication is a security/privacy issue and not recommended. Why would an application get all connection properties to HR DBs, for instance, just because there may be other "global defaults" I want to share amongst all the applications?

from spring-cloud-config.

spencergibb avatar spencergibb commented on May 24, 2024

Why would the hr db credentials be in the common file?

from spring-cloud-config.

emedina avatar emedina commented on May 24, 2024

Well, in any case, they are obfuscated.

Currently, we use one single credential for all applications (which of course it's not a good practice, but that's the current situation now).

from spring-cloud-config.

emedina avatar emedina commented on May 24, 2024

Using the Spring Profiles approach would definitively do the trick, though.

from spring-cloud-config.

qilaijun101 avatar qilaijun101 commented on May 24, 2024

ok,well done

from spring-cloud-config.

parameshjava avatar parameshjava commented on May 24, 2024

Observed that, application.yml configuration not overriden by respective service configuration, if service would need to modify the common properties. Is this expected behaviour?

from spring-cloud-config.

spencergibb avatar spencergibb commented on May 24, 2024

@parameshjava this has been working as designed for quite a long time.
If you can you provide a complete, minimal, verifiable sample that reproduces the problem, please open a new issue. It should be available as a GitHub (or similar) project or attached to the new issue as a zip file.

from spring-cloud-config.

parameshjava avatar parameshjava commented on May 24, 2024

@parameshjava this has been working as designed for quite a long time.
If you can you provide a complete, minimal, verifiable sample that reproduces the problem, please open a new issue. It should be available as a GitHub (or similar) project or attached to the new issue as a zip file.

@spencergibb thanks for your quick reply. Based on the search paths order it overriding the properties. It's working as expected, when placed base/shared configuration files path application-<profile>.yml is first searchable path.

from spring-cloud-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.